var Yt=Object.defineProperty;var Xt=(a,e,n)=>e in a?Yt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[e]=n;var nt=(a,e,n)=>(Xt(a,typeof e!="symbol"?e+"":e,n),n);import{s as safe_not_equal,e as element,a as space,t as text,c as claim_element,b as children,f as detach,g as claim_space,d as claim_text,L as get_svelte_dataset,o as attr,i as insert_hydration,h as append_hydration,p as listen,j as set_data,n as noop,q as createEventDispatcher,ae as select_value,T as add_render_callback,af as select_option,w as destroy_each,aa as set_input_value,x as create_slot,A as update_slot_base,B as get_all_dirty_from_scope,C as get_slot_changes,v as empty,D as compute_rest_props,k as component_subscribe,y as assign,E as exclude_internal_props,R as set_attributes,P as action_destroyer,M as run_all,N as bubble,a9 as set_store_value,ag as set_data_maybe_contenteditable,G as onMount,I as binding_callbacks,S as add_flush_callback,K as tick,l as svg_element,m as claim_svg_element,H as set_style,ah as prevent_default,ac as setContext,ad as getContext,a7 as onDestroy,F as afterUpdate,Q as is_function}from"../chunks/scheduler.Cq5UBZ1T.js";import{S as SvelteComponent,i as init,a as transition_in,t as transition_out,g as group_outros,c as check_outros,h as create_out_transition,j as create_in_transition,k as create_bidirectional_transition,b as create_component,d as claim_component,m as mount_component,e as destroy_component,f as bind}from"../chunks/index.D__UofN6.js";import{p as page}from"../chunks/stores.titGXIKi.js";import{d as getItemEmbeddings,e as getDatasetItem,p as postDatasetItem}from"../chunks/api.BxNj-TAm.js";import{j as setCtx,k as getCtx,l as getAttrs,m as disabledAttrs,n as getContent,o as setCtx$1,p as getCtx$1,r as getAttrs$1,t as setCtx$2,v as getAttrs$2,w as getCtx$2,x as getCtx$3,y as setCtx$3,z as getAttrs$3,A as setCtx$4,B as getAttrs$4,C as getCtx$4,c as cn,D as createCommand,E as createGroup,F as getCtx$5,G as getState,I as generateId,V as VALUE_ATTR,J as isBrowser,K as ITEM_SELECTOR,L as isHTMLInputElement,M as getGroup,N as isUndefined,O as isHTMLElement,h as flyAndScale,P as commonjsGlobal,Q as getDefaultExportFromCjs}from"../chunks/command.YXxPKXvy.js";import{c as createDispatcher,B as Button,P as PrimaryButton}from"../chunks/PrimaryButton.2luo0sZd.js";import{T as TooltipIconButton,R as Root$3,a as Trigger$2,b as Tooltip_content,C as ConfirmModal}from"../chunks/TooltipIconButton.h3qFl-sW.js";import{d as derived,w as writable,g as goto}from"../chunks/entry.BdqlkNrw.js";import{e as ensure_array_like,g as get_spread_update,a as get_spread_object,m as modelsStore$1,s as saveCurrentItemStore,d as datasetsStore,i as isLoadingNewItemStore}from"../chunks/datasetStores.BZ9GDOPp.js";import{I as Icon,L as Loader_2}from"../chunks/loader-2.Cz-VINyt.js";import{a as Check,C as Checkbox,W as WarningModal}from"../chunks/checkbox.OiMtEzVH.js";class InternMap extends Map{constructor(e,n=keyof){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),e!=null)for(const[t,r]of e)this.set(t,r)}get(e){return super.get(intern_get(this,e))}has(e){return super.has(intern_get(this,e))}set(e,n){return super.set(intern_set(this,e),n)}delete(e){return super.delete(intern_delete(this,e))}}function intern_get({_intern:a,_key:e},n){const t=e(n);return a.has(t)?a.get(t):n}function intern_set({_intern:a,_key:e},n){const t=e(n);return a.has(t)?a.get(t):(a.set(t,n),n)}function intern_delete({_intern:a,_key:e},n){const t=e(n);return a.has(t)&&(n=a.get(t),a.delete(t)),n}function keyof(a){return a!==null&&typeof a=="object"?a.valueOf():a}function initRange(a,e){switch(arguments.length){case 0:break;case 1:this.range(a);break;default:this.range(e).domain(a);break}return this}const implicit=Symbol("implicit");function ordinal(){var a=new InternMap,e=[],n=[],t=implicit;function r(o){let s=a.get(o);if(s===void 0){if(t!==implicit)return t;a.set(o,s=e.push(o)-1)}return n[s%n.length]}return r.domain=function(o){if(!arguments.length)return e.slice();e=[],a=new InternMap;for(const s of o)a.has(s)||a.set(s,e.push(s)-1);return r},r.range=function(o){return arguments.length?(n=Array.from(o),r):n.slice()},r.unknown=function(o){return arguments.length?(t=o,r):t},r.copy=function(){return ordinal(e,n).unknown(t)},initRange.apply(r,arguments),r}function colors(a){for(var e=a.length/6|0,n=new Array(e),t=0;t<e;)n[t]="#"+a.slice(t*6,++t*6);return n}const schemeSet3=colors("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f");/**
 * @copyright CEA
 * @author CEA
 * @license CECILL
 *
 * This software is a collaborative computer program whose purpose is to
 * generate and explore labeled data for computer vision applications.
 * This software is governed by the CeCILL-C license under French law and
 * abiding by the rules of distribution of free software. You can use,
 * modify and/ or redistribute the software under the terms of the CeCILL-C
 * license as circulated by CEA, CNRS and INRIA at the following URL
 *
 * http://www.cecill.info
 */function ordinalColorScale(a){return ordinal(schemeSet3).domain(a)}function get_each_context$c(a,e,n){const t=a.slice();return t[7]=e[n],t}function create_else_block$p(a){let e,n;return{c(){e=element("p"),n=text(a[2]),this.h()},l(t){e=claim_element(t,"P",{class:!0});var r=children(e);n=claim_text(r,a[2]),r.forEach(detach),this.h()},h(){attr(e,"class","pb-1 italic")},m(t,r){insert_hydration(t,e,r),append_hydration(e,n)},p(t,r){r&4&&set_data(n,t[2])},d(t){t&&detach(e)}}}function create_if_block$L(a){let e,n,t,r=ensure_array_like(a[3]),o=[];for(let s=0;s<r.length;s+=1)o[s]=create_each_block$c(get_each_context$c(a,r,s));return{c(){e=element("select");for(let s=0;s<o.length;s+=1)o[s].c();this.h()},l(s){e=claim_element(s,"SELECT",{class:!0});var l=children(e);for(let c=0;c<o.length;c+=1)o[c].l(l);l.forEach(detach),this.h()},h(){attr(e,"class","py-1 px-2 border rounded focus:outline-none bg-slate-100 border-slate-300 focus:border-main"),a[0]===void 0&&add_render_callback(()=>a[5].call(e))},m(s,l){insert_hydration(s,e,l);for(let c=0;c<o.length;c+=1)o[c]&&o[c].m(e,null);select_option(e,a[0],!0),n||(t=listen(e,"change",a[5]),n=!0)},p(s,l){if(l&8){r=ensure_array_like(s[3]);let c;for(c=0;c<r.length;c+=1){const f=get_each_context$c(s,r,c);o[c]?o[c].p(f,l):(o[c]=create_each_block$c(f),o[c].c(),o[c].m(e,null))}for(;c<o.length;c+=1)o[c].d(1);o.length=r.length}l&9&&select_option(e,s[0])},d(s){s&&detach(e),destroy_each(o,s),n=!1,t()}}}function create_each_block$c(a){let e,n=a[7]+"",t,r,o;return{c(){e=element("option"),t=text(n),r=space(),this.h()},l(s){e=claim_element(s,"OPTION",{});var l=children(e);t=claim_text(l,n),r=claim_space(l),l.forEach(detach),this.h()},h(){e.__value=o=a[7],set_input_value(e,e.__value)},m(s,l){insert_hydration(s,e,l),append_hydration(e,t),append_hydration(e,r)},p(s,l){l&8&&n!==(n=s[7]+"")&&set_data(t,n),l&8&&o!==(o=s[7])&&(e.__value=o,set_input_value(e,e.__value))},d(s){s&&detach(e)}}}function create_fragment$1w(a){let e,n,t,r,o,s,l,c,f,h,u="Ok",i,d;function p(g,b){return g[3]?create_if_block$L:create_else_block$p}let _=p(a),m=_(a);return{c(){e=element("div"),n=element("div"),t=space(),r=element("div"),o=element("div"),s=element("p"),l=text(a[1]),c=space(),m.c(),f=space(),h=element("button"),h.textContent=u,this.h()},l(g){e=claim_element(g,"DIV",{class:!0});var b=children(e);n=claim_element(b,"DIV",{class:!0}),children(n).forEach(detach),t=claim_space(b),r=claim_element(b,"DIV",{class:!0});var v=children(r);o=claim_element(v,"DIV",{class:!0});var T=children(o);s=claim_element(T,"P",{class:!0});var y=children(s);l=claim_text(y,a[1]),y.forEach(detach),c=claim_space(T),m.l(T),f=claim_space(T),h=claim_element(T,"BUTTON",{type:!0,class:!0,"data-svelte-h":!0}),get_svelte_dataset(h)!=="svelte-fnm6uk"&&(h.textContent=u),T.forEach(detach),v.forEach(detach),b.forEach(detach),this.h()},h(){attr(n,"class","fixed inset-0 bg-black bg-opacity-50 transition-opacity"),attr(s,"class","pb-1"),attr(h,"type","button"),attr(h,"class","rounded border border-transparent text-slate-50 mt-3 mx-1 py-1 px-3 bg-primary transition-colors hover:bg-primary-foreground"),attr(o,"class","relative transform overflow-hidden rounded-lg p-6 max-w-2xl bg-slate-50 text-slate-800"),attr(r,"class","flex min-h-full justify-center text-center items-center"),attr(e,"class","fixed inset-0 z-50 overflow-y-auto")},m(g,b){insert_hydration(g,e,b),append_hydration(e,n),append_hydration(e,t),append_hydration(e,r),append_hydration(r,o),append_hydration(o,s),append_hydration(s,l),append_hydration(o,c),m.m(o,null),append_hydration(o,f),append_hydration(o,h),i||(d=listen(h,"click",a[4]),i=!0)},p(g,[b]){b&2&&set_data(l,g[1]),_===(_=p(g))&&m?m.p(g,b):(m.d(1),m=_(g),m&&(m.c(),m.m(o,f)))},i:noop,o:noop,d(g){g&&detach(e),m.d(),i=!1,d()}}}function instance$1A(a,e,n){let{message:t}=e,{ifNoChoices:r}=e,{choices:o}=e,{selected:s}=e;const l=createEventDispatcher();function c(){l("confirm")}function f(){s=select_value(this),n(0,s),n(3,o)}return a.$$set=h=>{"message"in h&&n(1,t=h.message),"ifNoChoices"in h&&n(2,r=h.ifNoChoices),"choices"in h&&n(3,o=h.choices),"selected"in h&&n(0,s=h.selected)},[s,t,r,o,c,f]}class SelectModal extends SvelteComponent{constructor(e){super(),init(this,e,instance$1A,create_fragment$1w,safe_not_equal,{message:1,ifNoChoices:2,choices:3,selected:0})}}const get_default_slot_changes$k=a=>({}),get_default_slot_context$k=a=>({ids:a[0]});function create_fragment$1v(a){let e;const n=a[16].default,t=create_slot(n,a,a[15],get_default_slot_context$k);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,[o]){t&&t.p&&(!e||o&32768)&&update_slot_base(t,n,r,r[15],e?get_slot_changes(n,r[15],o,get_default_slot_changes$k):get_all_dirty_from_scope(r[15]),get_default_slot_context$k)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function instance$1z(a,e,n){let{$$slots:t={},$$scope:r}=e,{closeOnOutsideClick:o=void 0}=e,{closeOnEscape:s=void 0}=e,{portal:l=void 0}=e,{forceVisible:c=!0}=e,{open:f=void 0}=e,{onOpenChange:h=void 0}=e,{preventScroll:u=void 0}=e,{arrowSize:i=void 0}=e,{positioning:d=void 0}=e,{loop:p=void 0}=e,{dir:_=void 0}=e,{typeahead:m=void 0}=e,{closeFocus:g=void 0}=e,{disableFocusFirstItem:b=void 0}=e;const{states:{open:v},updateOption:T,ids:y}=setCtx({closeOnOutsideClick:o,closeOnEscape:s,portal:l,forceVisible:c,defaultOpen:f,preventScroll:u,arrowSize:i,positioning:d,loop:p,dir:_,typeahead:m,disableFocusFirstItem:b,closeFocus:g,onOpenChange:({next:w})=>(f!==w&&(h==null||h(w),n(1,f=w)),w)});return a.$$set=w=>{"closeOnOutsideClick"in w&&n(2,o=w.closeOnOutsideClick),"closeOnEscape"in w&&n(3,s=w.closeOnEscape),"portal"in w&&n(4,l=w.portal),"forceVisible"in w&&n(5,c=w.forceVisible),"open"in w&&n(1,f=w.open),"onOpenChange"in w&&n(6,h=w.onOpenChange),"preventScroll"in w&&n(7,u=w.preventScroll),"arrowSize"in w&&n(8,i=w.arrowSize),"positioning"in w&&n(9,d=w.positioning),"loop"in w&&n(10,p=w.loop),"dir"in w&&n(11,_=w.dir),"typeahead"in w&&n(12,m=w.typeahead),"closeFocus"in w&&n(13,g=w.closeFocus),"disableFocusFirstItem"in w&&n(14,b=w.disableFocusFirstItem),"$$scope"in w&&n(15,r=w.$$scope)},a.$$.update=()=>{a.$$.dirty&2&&f!==void 0&&v.set(f),a.$$.dirty&4&&T("closeOnOutsideClick",o),a.$$.dirty&8&&T("closeOnEscape",s),a.$$.dirty&16&&T("portal",l),a.$$.dirty&32&&T("forceVisible",c),a.$$.dirty&128&&T("preventScroll",u),a.$$.dirty&256&&T("arrowSize",i),a.$$.dirty&512&&T("positioning",d),a.$$.dirty&1024&&T("loop",p),a.$$.dirty&2048&&T("dir",_),a.$$.dirty&8192&&T("closeFocus",g),a.$$.dirty&16384&&T("disableFocusFirstItem",b),a.$$.dirty&4096&&T("typeahead",m)},[y,f,o,s,l,c,h,u,i,d,p,_,m,g,b,r,t]}class ContextMenu extends SvelteComponent{constructor(e){super(),init(this,e,instance$1z,create_fragment$1v,safe_not_equal,{closeOnOutsideClick:2,closeOnEscape:3,portal:4,forceVisible:5,open:1,onOpenChange:6,preventScroll:7,arrowSize:8,positioning:9,loop:10,dir:11,typeahead:12,closeFocus:13,disableFocusFirstItem:14})}}const get_default_slot_changes_1$d=a=>({builder:a&4,attrs:a&2}),get_default_slot_context_1$d=a=>({builder:a[2],attrs:a[1]}),get_default_slot_changes$j=a=>({builder:a&4,attrs:a&2}),get_default_slot_context$j=a=>({builder:a[2],attrs:a[1]});function create_else_block$o(a){let e,n,t,r;const o=a[9].default,s=create_slot(o,a,a[8],get_default_slot_context_1$d);let l=[a[2],a[5],a[1]],c={};for(let f=0;f<l.length;f+=1)c=assign(c,l[f]);return{c(){e=element("div"),s&&s.c(),this.h()},l(f){e=claim_element(f,"DIV",{});var h=children(e);s&&s.l(h),h.forEach(detach),this.h()},h(){set_attributes(e,c)},m(f,h){insert_hydration(f,e,h),s&&s.m(e,null),n=!0,t||(r=[action_destroyer(a[2].action(e)),listen(e,"m-click",a[4]),listen(e,"m-focusin",a[4]),listen(e,"m-focusout",a[4]),listen(e,"m-keydown",a[4]),listen(e,"m-pointerdown",a[4]),listen(e,"m-pointerleave",a[4]),listen(e,"m-pointermove",a[4])],t=!0)},p(f,h){s&&s.p&&(!n||h&262)&&update_slot_base(s,o,f,f[8],n?get_slot_changes(o,f[8],h,get_default_slot_changes_1$d):get_all_dirty_from_scope(f[8]),get_default_slot_context_1$d),set_attributes(e,c=get_spread_update(l,[h&4&&f[2],h&32&&f[5],h&2&&f[1]]))},i(f){n||(transition_in(s,f),n=!0)},o(f){transition_out(s,f),n=!1},d(f){f&&detach(e),s&&s.d(f),t=!1,run_all(r)}}}function create_if_block$K(a){let e;const n=a[9].default,t=create_slot(n,a,a[8],get_default_slot_context$j);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&262)&&update_slot_base(t,n,r,r[8],e?get_slot_changes(n,r[8],o,get_default_slot_changes$j):get_all_dirty_from_scope(r[8]),get_default_slot_context$j)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$1u(a){let e,n,t,r;const o=[create_if_block$K,create_else_block$o],s=[];function l(c,f){return c[0]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){let h=e;e=l(c),e===h?s[e].p(c,f):(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function instance$1y(a,e,n){let t,r;const o=["asChild","disabled"];let s=compute_rest_props(e,o),l,{$$slots:c={},$$scope:f}=e,{asChild:h=!1}=e,{disabled:u=!1}=e;const{elements:{item:i}}=getCtx();component_subscribe(a,i,p=>n(7,l=p));const d=createDispatcher();return a.$$set=p=>{e=assign(assign({},e),exclude_internal_props(p)),n(5,s=compute_rest_props(e,o)),"asChild"in p&&n(0,h=p.asChild),"disabled"in p&&n(6,u=p.disabled),"$$scope"in p&&n(8,f=p.$$scope)},a.$$.update=()=>{a.$$.dirty&128&&n(2,t=l),a.$$.dirty&64&&n(1,r={...getAttrs("item"),...disabledAttrs(u)})},[h,r,t,i,d,s,u,l,f,c]}class ContextMenuItem extends SvelteComponent{constructor(e){super(),init(this,e,instance$1y,create_fragment$1u,safe_not_equal,{asChild:0,disabled:6})}}const get_default_slot_changes_5$1=a=>({builder:a&128}),get_default_slot_context_5$1=a=>({builder:a[7],attrs:a[12]}),get_default_slot_changes_4$1=a=>({builder:a&128}),get_default_slot_context_4$1=a=>({builder:a[7],attrs:a[12]}),get_default_slot_changes_3$1=a=>({builder:a&128}),get_default_slot_context_3$1=a=>({builder:a[7],attrs:a[12]}),get_default_slot_changes_2$1=a=>({builder:a&128}),get_default_slot_context_2$1=a=>({builder:a[7],attrs:a[12]}),get_default_slot_changes_1$c=a=>({builder:a&128}),get_default_slot_context_1$c=a=>({builder:a[7],attrs:a[12]}),get_default_slot_changes$i=a=>({builder:a&128}),get_default_slot_context$i=a=>({builder:a[7],attrs:a[12]});function create_if_block_5$2(a){let e,n,t,r;const o=a[18].default,s=create_slot(o,a,a[17],get_default_slot_context_5$1);let l=[a[7],a[13],a[12]],c={};for(let f=0;f<l.length;f+=1)c=assign(c,l[f]);return{c(){e=element("div"),s&&s.c(),this.h()},l(f){e=claim_element(f,"DIV",{});var h=children(e);s&&s.l(h),h.forEach(detach),this.h()},h(){set_attributes(e,c)},m(f,h){insert_hydration(f,e,h),s&&s.m(e,null),n=!0,t||(r=[action_destroyer(a[7].action(e)),listen(e,"m-keydown",a[11])],t=!0)},p(f,h){s&&s.p&&(!n||h&131200)&&update_slot_base(s,o,f,f[17],n?get_slot_changes(o,f[17],h,get_default_slot_changes_5$1):get_all_dirty_from_scope(f[17]),get_default_slot_context_5$1),set_attributes(e,c=get_spread_update(l,[h&128&&f[7],h&8192&&f[13],f[12]]))},i(f){n||(transition_in(s,f),n=!0)},o(f){transition_out(s,f),n=!1},d(f){f&&detach(e),s&&s.d(f),t=!1,run_all(r)}}}function create_if_block_4$4(a){let e,n,t,r,o;const s=a[18].default,l=create_slot(s,a,a[17],get_default_slot_context_4$1);let c=[a[7],a[13],a[12]],f={};for(let h=0;h<c.length;h+=1)f=assign(f,c[h]);return{c(){e=element("div"),l&&l.c(),this.h()},l(h){e=claim_element(h,"DIV",{});var u=children(e);l&&l.l(u),u.forEach(detach),this.h()},h(){set_attributes(e,f)},m(h,u){insert_hydration(h,e,u),l&&l.m(e,null),t=!0,r||(o=[action_destroyer(a[7].action(e)),listen(e,"m-keydown",a[11])],r=!0)},p(h,u){a=h,l&&l.p&&(!t||u&131200)&&update_slot_base(l,s,a,a[17],t?get_slot_changes(s,a[17],u,get_default_slot_changes_4$1):get_all_dirty_from_scope(a[17]),get_default_slot_context_4$1),set_attributes(e,f=get_spread_update(c,[u&128&&a[7],u&8192&&a[13],a[12]]))},i(h){t||(transition_in(l,h),n&&n.end(1),t=!0)},o(h){transition_out(l,h),h&&(n=create_out_transition(e,a[4],a[5])),t=!1},d(h){h&&detach(e),l&&l.d(h),h&&n&&n.end(),r=!1,run_all(o)}}}function create_if_block_3$8(a){let e,n,t,r,o;const s=a[18].default,l=create_slot(s,a,a[17],get_default_slot_context_3$1);let c=[a[7],a[13],a[12]],f={};for(let h=0;h<c.length;h+=1)f=assign(f,c[h]);return{c(){e=element("div"),l&&l.c(),this.h()},l(h){e=claim_element(h,"DIV",{});var u=children(e);l&&l.l(u),u.forEach(detach),this.h()},h(){set_attributes(e,f)},m(h,u){insert_hydration(h,e,u),l&&l.m(e,null),t=!0,r||(o=[action_destroyer(a[7].action(e)),listen(e,"m-keydown",a[11])],r=!0)},p(h,u){a=h,l&&l.p&&(!t||u&131200)&&update_slot_base(l,s,a,a[17],t?get_slot_changes(s,a[17],u,get_default_slot_changes_3$1):get_all_dirty_from_scope(a[17]),get_default_slot_context_3$1),set_attributes(e,f=get_spread_update(c,[u&128&&a[7],u&8192&&a[13],a[12]]))},i(h){t||(transition_in(l,h),h&&(n||add_render_callback(()=>{n=create_in_transition(e,a[2],a[3]),n.start()})),t=!0)},o(h){transition_out(l,h),t=!1},d(h){h&&detach(e),l&&l.d(h),r=!1,run_all(o)}}}function create_if_block_2$b(a){let e,n,t,r,o,s;const l=a[18].default,c=create_slot(l,a,a[17],get_default_slot_context_2$1);let f=[a[7],a[13],a[12]],h={};for(let u=0;u<f.length;u+=1)h=assign(h,f[u]);return{c(){e=element("div"),c&&c.c(),this.h()},l(u){e=claim_element(u,"DIV",{});var i=children(e);c&&c.l(i),i.forEach(detach),this.h()},h(){set_attributes(e,h)},m(u,i){insert_hydration(u,e,i),c&&c.m(e,null),r=!0,o||(s=[action_destroyer(a[7].action(e)),listen(e,"m-keydown",a[11])],o=!0)},p(u,i){a=u,c&&c.p&&(!r||i&131200)&&update_slot_base(c,l,a,a[17],r?get_slot_changes(l,a[17],i,get_default_slot_changes_2$1):get_all_dirty_from_scope(a[17]),get_default_slot_context_2$1),set_attributes(e,h=get_spread_update(f,[i&128&&a[7],i&8192&&a[13],a[12]]))},i(u){r||(transition_in(c,u),u&&add_render_callback(()=>{r&&(t&&t.end(1),n=create_in_transition(e,a[2],a[3]),n.start())}),r=!0)},o(u){transition_out(c,u),n&&n.invalidate(),u&&(t=create_out_transition(e,a[4],a[5])),r=!1},d(u){u&&detach(e),c&&c.d(u),u&&t&&t.end(),o=!1,run_all(s)}}}function create_if_block_1$j(a){let e,n,t,r,o;const s=a[18].default,l=create_slot(s,a,a[17],get_default_slot_context_1$c);let c=[a[7],a[13],a[12]],f={};for(let h=0;h<c.length;h+=1)f=assign(f,c[h]);return{c(){e=element("div"),l&&l.c(),this.h()},l(h){e=claim_element(h,"DIV",{});var u=children(e);l&&l.l(u),u.forEach(detach),this.h()},h(){set_attributes(e,f)},m(h,u){insert_hydration(h,e,u),l&&l.m(e,null),t=!0,r||(o=[action_destroyer(a[7].action(e)),listen(e,"m-keydown",a[11])],r=!0)},p(h,u){a=h,l&&l.p&&(!t||u&131200)&&update_slot_base(l,s,a,a[17],t?get_slot_changes(s,a[17],u,get_default_slot_changes_1$c):get_all_dirty_from_scope(a[17]),get_default_slot_context_1$c),set_attributes(e,f=get_spread_update(c,[u&128&&a[7],u&8192&&a[13],a[12]]))},i(h){t||(transition_in(l,h),h&&add_render_callback(()=>{t&&(n||(n=create_bidirectional_transition(e,a[0],a[1],!0)),n.run(1))}),t=!0)},o(h){transition_out(l,h),h&&(n||(n=create_bidirectional_transition(e,a[0],a[1],!1)),n.run(0)),t=!1},d(h){h&&detach(e),l&&l.d(h),h&&n&&n.end(),r=!1,run_all(o)}}}function create_if_block$J(a){let e;const n=a[18].default,t=create_slot(n,a,a[17],get_default_slot_context$i);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&131200)&&update_slot_base(t,n,r,r[17],e?get_slot_changes(n,r[17],o,get_default_slot_changes$i):get_all_dirty_from_scope(r[17]),get_default_slot_context$i)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$1t(a){let e,n,t,r;const o=[create_if_block$J,create_if_block_1$j,create_if_block_2$b,create_if_block_3$8,create_if_block_4$4,create_if_block_5$2],s=[];function l(c,f){return c[6]&&c[8]?0:c[0]&&c[8]?1:c[2]&&c[4]&&c[8]?2:c[2]&&c[8]?3:c[4]&&c[8]?4:c[8]?5:-1}return~(e=l(a))&&(n=s[e]=o[e](a)),{c(){n&&n.c(),t=empty()},l(c){n&&n.l(c),t=empty()},m(c,f){~e&&s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){let h=e;e=l(c),e===h?~e&&s[e].p(c,f):(n&&(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros()),~e?(n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t)):n=null)},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),~e&&s[e].d(c)}}}function instance$1x(a,e,n){let t;const r=["sideOffset","transition","transitionConfig","inTransition","inTransitionConfig","outTransition","outTransitionConfig","asChild","id"];let o=compute_rest_props(e,r),s,l,{$$slots:c={},$$scope:f}=e,{sideOffset:h=5}=e,{transition:u=void 0}=e,{transitionConfig:i=void 0}=e,{inTransition:d=void 0}=e,{inTransitionConfig:p=void 0}=e,{outTransition:_=void 0}=e,{outTransitionConfig:m=void 0}=e,{asChild:g=!1}=e,{id:b=void 0}=e;const{elements:{menu:v},states:{open:T},ids:y}=getContent(h);component_subscribe(a,v,O=>n(16,s=O)),component_subscribe(a,T,O=>n(8,l=O));const w=createDispatcher(),S=getAttrs("content");return a.$$set=O=>{e=assign(assign({},e),exclude_internal_props(O)),n(13,o=compute_rest_props(e,r)),"sideOffset"in O&&n(14,h=O.sideOffset),"transition"in O&&n(0,u=O.transition),"transitionConfig"in O&&n(1,i=O.transitionConfig),"inTransition"in O&&n(2,d=O.inTransition),"inTransitionConfig"in O&&n(3,p=O.inTransitionConfig),"outTransition"in O&&n(4,_=O.outTransition),"outTransitionConfig"in O&&n(5,m=O.outTransitionConfig),"asChild"in O&&n(6,g=O.asChild),"id"in O&&n(15,b=O.id),"$$scope"in O&&n(17,f=O.$$scope)},a.$$.update=()=>{a.$$.dirty&32768&&b&&y.menu.set(b),a.$$.dirty&65536&&n(7,t=s)},[u,i,d,p,_,m,g,t,l,v,T,w,S,o,h,b,s,f,c]}class ContextMenuContent extends SvelteComponent{constructor(e){super(),init(this,e,instance$1x,create_fragment$1t,safe_not_equal,{sideOffset:14,transition:0,transitionConfig:1,inTransition:2,inTransitionConfig:3,outTransition:4,outTransitionConfig:5,asChild:6,id:15})}}const get_default_slot_changes_1$b=a=>({builder:a&2}),get_default_slot_context_1$b=a=>({builder:a[1],attrs:a[4]}),get_default_slot_changes$h=a=>({builder:a&2}),get_default_slot_context$h=a=>({builder:a[1],attrs:a[4]});function create_else_block$n(a){let e,n,t,r;const o=a[9].default,s=create_slot(o,a,a[8],get_default_slot_context_1$b);let l=[a[1],a[5],a[4]],c={};for(let f=0;f<l.length;f+=1)c=assign(c,l[f]);return{c(){e=element("div"),s&&s.c(),this.h()},l(f){e=claim_element(f,"DIV",{});var h=children(e);s&&s.l(h),h.forEach(detach),this.h()},h(){set_attributes(e,c)},m(f,h){insert_hydration(f,e,h),s&&s.m(e,null),n=!0,t||(r=[action_destroyer(a[1].action(e)),listen(e,"m-contextmenu",a[3]),listen(e,"m-pointercancel",a[3]),listen(e,"m-pointerdown",a[3]),listen(e,"m-pointermove",a[3]),listen(e,"m-pointerup",a[3])],t=!0)},p(f,h){s&&s.p&&(!n||h&258)&&update_slot_base(s,o,f,f[8],n?get_slot_changes(o,f[8],h,get_default_slot_changes_1$b):get_all_dirty_from_scope(f[8]),get_default_slot_context_1$b),set_attributes(e,c=get_spread_update(l,[h&2&&f[1],h&32&&f[5],f[4]]))},i(f){n||(transition_in(s,f),n=!0)},o(f){transition_out(s,f),n=!1},d(f){f&&detach(e),s&&s.d(f),t=!1,run_all(r)}}}function create_if_block$I(a){let e;const n=a[9].default,t=create_slot(n,a,a[8],get_default_slot_context$h);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&258)&&update_slot_base(t,n,r,r[8],e?get_slot_changes(n,r[8],o,get_default_slot_changes$h):get_all_dirty_from_scope(r[8]),get_default_slot_context$h)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$1s(a){let e,n,t,r;const o=[create_if_block$I,create_else_block$n],s=[];function l(c,f){return c[0]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){let h=e;e=l(c),e===h?s[e].p(c,f):(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function instance$1w(a,e,n){let t;const r=["asChild","id"];let o=compute_rest_props(e,r),s,{$$slots:l={},$$scope:c}=e,{asChild:f=!1}=e,{id:h=void 0}=e;const{elements:{trigger:u},ids:i}=getCtx();component_subscribe(a,u,_=>n(7,s=_));const d=createDispatcher(),p=getAttrs("trigger");return a.$$set=_=>{e=assign(assign({},e),exclude_internal_props(_)),n(5,o=compute_rest_props(e,r)),"asChild"in _&&n(0,f=_.asChild),"id"in _&&n(6,h=_.id),"$$scope"in _&&n(8,c=_.$$scope)},a.$$.update=()=>{a.$$.dirty&64&&h&&i.trigger.set(h),a.$$.dirty&128&&n(1,t=s)},[f,t,u,d,p,o,h,s,c,l]}class ContextMenuTrigger extends SvelteComponent{constructor(e){super(),init(this,e,instance$1w,create_fragment$1s,safe_not_equal,{asChild:0,id:6})}}const get_default_slot_changes$g=a=>({ids:a&1}),get_default_slot_context$g=a=>({ids:a[0]});function create_fragment$1r(a){let e;const n=a[14].default,t=create_slot(n,a,a[13],get_default_slot_context$g);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,[o]){t&&t.p&&(!e||o&8193)&&update_slot_base(t,n,r,r[13],e?get_slot_changes(n,r[13],o,get_default_slot_changes$g):get_all_dirty_from_scope(r[13]),get_default_slot_context$g)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function instance$1v(a,e,n){let t,{$$slots:r={},$$scope:o}=e,{positioning:s=void 0}=e,{arrowSize:l=void 0}=e,{disableFocusTrap:c=void 0}=e,{closeOnEscape:f=void 0}=e,{closeOnOutsideClick:h=void 0}=e,{preventScroll:u=void 0}=e,{portal:i=void 0}=e,{open:d=void 0}=e,{onOpenChange:p=void 0}=e,{openFocus:_=void 0}=e,{closeFocus:m=void 0}=e;const{updateOption:g,states:{open:b},ids:v}=setCtx$1({positioning:s,arrowSize:l,disableFocusTrap:c,closeOnEscape:f,closeOnOutsideClick:h,preventScroll:u,portal:i,defaultOpen:d,openFocus:_,closeFocus:m,onOpenChange:({next:y})=>(d!==y&&(p==null||p(y),n(2,d=y)),y)}),T=derived([v.content,v.trigger],([y,w])=>({content:y,trigger:w}));return component_subscribe(a,T,y=>n(0,t=y)),a.$$set=y=>{"positioning"in y&&n(3,s=y.positioning),"arrowSize"in y&&n(4,l=y.arrowSize),"disableFocusTrap"in y&&n(5,c=y.disableFocusTrap),"closeOnEscape"in y&&n(6,f=y.closeOnEscape),"closeOnOutsideClick"in y&&n(7,h=y.closeOnOutsideClick),"preventScroll"in y&&n(8,u=y.preventScroll),"portal"in y&&n(9,i=y.portal),"open"in y&&n(2,d=y.open),"onOpenChange"in y&&n(10,p=y.onOpenChange),"openFocus"in y&&n(11,_=y.openFocus),"closeFocus"in y&&n(12,m=y.closeFocus),"$$scope"in y&&n(13,o=y.$$scope)},a.$$.update=()=>{a.$$.dirty&4&&d!==void 0&&b.set(d),a.$$.dirty&8&&g("positioning",s),a.$$.dirty&16&&g("arrowSize",l),a.$$.dirty&32&&g("disableFocusTrap",c),a.$$.dirty&64&&g("closeOnEscape",f),a.$$.dirty&128&&g("closeOnOutsideClick",h),a.$$.dirty&256&&g("preventScroll",u),a.$$.dirty&512&&g("portal",i),a.$$.dirty&2048&&g("openFocus",_),a.$$.dirty&4096&&g("closeFocus",m)},[t,T,d,s,l,c,f,h,u,i,p,_,m,o,r]}class Popover extends SvelteComponent{constructor(e){super(),init(this,e,instance$1v,create_fragment$1r,safe_not_equal,{positioning:3,arrowSize:4,disableFocusTrap:5,closeOnEscape:6,closeOnOutsideClick:7,preventScroll:8,portal:9,open:2,onOpenChange:10,openFocus:11,closeFocus:12})}}const get_default_slot_changes_5=a=>({builder:a&128}),get_default_slot_context_5=a=>({builder:a[7],attrs:a[11]}),get_default_slot_changes_4=a=>({builder:a&128}),get_default_slot_context_4=a=>({builder:a[7],attrs:a[11]}),get_default_slot_changes_3=a=>({builder:a&128}),get_default_slot_context_3=a=>({builder:a[7],attrs:a[11]}),get_default_slot_changes_2=a=>({builder:a&128}),get_default_slot_context_2=a=>({builder:a[7],attrs:a[11]}),get_default_slot_changes_1$a=a=>({builder:a&128}),get_default_slot_context_1$a=a=>({builder:a[7],attrs:a[11]}),get_default_slot_changes$f=a=>({builder:a&128}),get_default_slot_context$f=a=>({builder:a[7],attrs:a[11]});function create_if_block_5$1(a){let e,n,t,r;const o=a[16].default,s=create_slot(o,a,a[15],get_default_slot_context_5);let l=[a[7],a[12],a[11]],c={};for(let f=0;f<l.length;f+=1)c=assign(c,l[f]);return{c(){e=element("div"),s&&s.c(),this.h()},l(f){e=claim_element(f,"DIV",{});var h=children(e);s&&s.l(h),h.forEach(detach),this.h()},h(){set_attributes(e,c)},m(f,h){insert_hydration(f,e,h),s&&s.m(e,null),n=!0,t||(r=action_destroyer(a[7].action(e)),t=!0)},p(f,h){s&&s.p&&(!n||h&32896)&&update_slot_base(s,o,f,f[15],n?get_slot_changes(o,f[15],h,get_default_slot_changes_5):get_all_dirty_from_scope(f[15]),get_default_slot_context_5),set_attributes(e,c=get_spread_update(l,[h&128&&f[7],h&4096&&f[12],f[11]]))},i(f){n||(transition_in(s,f),n=!0)},o(f){transition_out(s,f),n=!1},d(f){f&&detach(e),s&&s.d(f),t=!1,r()}}}function create_if_block_4$3(a){let e,n,t,r,o;const s=a[16].default,l=create_slot(s,a,a[15],get_default_slot_context_4);let c=[a[7],a[12],a[11]],f={};for(let h=0;h<c.length;h+=1)f=assign(f,c[h]);return{c(){e=element("div"),l&&l.c(),this.h()},l(h){e=claim_element(h,"DIV",{});var u=children(e);l&&l.l(u),u.forEach(detach),this.h()},h(){set_attributes(e,f)},m(h,u){insert_hydration(h,e,u),l&&l.m(e,null),t=!0,r||(o=action_destroyer(a[7].action(e)),r=!0)},p(h,u){a=h,l&&l.p&&(!t||u&32896)&&update_slot_base(l,s,a,a[15],t?get_slot_changes(s,a[15],u,get_default_slot_changes_4):get_all_dirty_from_scope(a[15]),get_default_slot_context_4),set_attributes(e,f=get_spread_update(c,[u&128&&a[7],u&4096&&a[12],a[11]]))},i(h){t||(transition_in(l,h),n&&n.end(1),t=!0)},o(h){transition_out(l,h),h&&(n=create_out_transition(e,a[4],a[5])),t=!1},d(h){h&&detach(e),l&&l.d(h),h&&n&&n.end(),r=!1,o()}}}function create_if_block_3$7(a){let e,n,t,r,o;const s=a[16].default,l=create_slot(s,a,a[15],get_default_slot_context_3);let c=[a[7],a[12],a[11]],f={};for(let h=0;h<c.length;h+=1)f=assign(f,c[h]);return{c(){e=element("div"),l&&l.c(),this.h()},l(h){e=claim_element(h,"DIV",{});var u=children(e);l&&l.l(u),u.forEach(detach),this.h()},h(){set_attributes(e,f)},m(h,u){insert_hydration(h,e,u),l&&l.m(e,null),t=!0,r||(o=action_destroyer(a[7].action(e)),r=!0)},p(h,u){a=h,l&&l.p&&(!t||u&32896)&&update_slot_base(l,s,a,a[15],t?get_slot_changes(s,a[15],u,get_default_slot_changes_3):get_all_dirty_from_scope(a[15]),get_default_slot_context_3),set_attributes(e,f=get_spread_update(c,[u&128&&a[7],u&4096&&a[12],a[11]]))},i(h){t||(transition_in(l,h),h&&(n||add_render_callback(()=>{n=create_in_transition(e,a[2],a[3]),n.start()})),t=!0)},o(h){transition_out(l,h),t=!1},d(h){h&&detach(e),l&&l.d(h),r=!1,o()}}}function create_if_block_2$a(a){let e,n,t,r,o,s;const l=a[16].default,c=create_slot(l,a,a[15],get_default_slot_context_2);let f=[a[7],a[12],a[11]],h={};for(let u=0;u<f.length;u+=1)h=assign(h,f[u]);return{c(){e=element("div"),c&&c.c(),this.h()},l(u){e=claim_element(u,"DIV",{});var i=children(e);c&&c.l(i),i.forEach(detach),this.h()},h(){set_attributes(e,h)},m(u,i){insert_hydration(u,e,i),c&&c.m(e,null),r=!0,o||(s=action_destroyer(a[7].action(e)),o=!0)},p(u,i){a=u,c&&c.p&&(!r||i&32896)&&update_slot_base(c,l,a,a[15],r?get_slot_changes(l,a[15],i,get_default_slot_changes_2):get_all_dirty_from_scope(a[15]),get_default_slot_context_2),set_attributes(e,h=get_spread_update(f,[i&128&&a[7],i&4096&&a[12],a[11]]))},i(u){r||(transition_in(c,u),u&&add_render_callback(()=>{r&&(t&&t.end(1),n=create_in_transition(e,a[2],a[3]),n.start())}),r=!0)},o(u){transition_out(c,u),n&&n.invalidate(),u&&(t=create_out_transition(e,a[4],a[5])),r=!1},d(u){u&&detach(e),c&&c.d(u),u&&t&&t.end(),o=!1,s()}}}function create_if_block_1$i(a){let e,n,t,r,o;const s=a[16].default,l=create_slot(s,a,a[15],get_default_slot_context_1$a);let c=[a[7],a[12],a[11]],f={};for(let h=0;h<c.length;h+=1)f=assign(f,c[h]);return{c(){e=element("div"),l&&l.c(),this.h()},l(h){e=claim_element(h,"DIV",{});var u=children(e);l&&l.l(u),u.forEach(detach),this.h()},h(){set_attributes(e,f)},m(h,u){insert_hydration(h,e,u),l&&l.m(e,null),t=!0,r||(o=action_destroyer(a[7].action(e)),r=!0)},p(h,u){a=h,l&&l.p&&(!t||u&32896)&&update_slot_base(l,s,a,a[15],t?get_slot_changes(s,a[15],u,get_default_slot_changes_1$a):get_all_dirty_from_scope(a[15]),get_default_slot_context_1$a),set_attributes(e,f=get_spread_update(c,[u&128&&a[7],u&4096&&a[12],a[11]]))},i(h){t||(transition_in(l,h),h&&add_render_callback(()=>{t&&(n||(n=create_bidirectional_transition(e,a[0],a[1],!0)),n.run(1))}),t=!0)},o(h){transition_out(l,h),h&&(n||(n=create_bidirectional_transition(e,a[0],a[1],!1)),n.run(0)),t=!1},d(h){h&&detach(e),l&&l.d(h),h&&n&&n.end(),r=!1,o()}}}function create_if_block$H(a){let e;const n=a[16].default,t=create_slot(n,a,a[15],get_default_slot_context$f);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&32896)&&update_slot_base(t,n,r,r[15],e?get_slot_changes(n,r[15],o,get_default_slot_changes$f):get_all_dirty_from_scope(r[15]),get_default_slot_context$f)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$1q(a){let e,n,t,r;const o=[create_if_block$H,create_if_block_1$i,create_if_block_2$a,create_if_block_3$7,create_if_block_4$3,create_if_block_5$1],s=[];function l(c,f){return c[6]&&c[8]?0:c[0]&&c[8]?1:c[2]&&c[4]&&c[8]?2:c[2]&&c[8]?3:c[4]&&c[8]?4:c[8]?5:-1}return~(e=l(a))&&(n=s[e]=o[e](a)),{c(){n&&n.c(),t=empty()},l(c){n&&n.l(c),t=empty()},m(c,f){~e&&s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){let h=e;e=l(c),e===h?~e&&s[e].p(c,f):(n&&(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros()),~e?(n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t)):n=null)},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),~e&&s[e].d(c)}}}function instance$1u(a,e,n){let t;const r=["transition","transitionConfig","inTransition","inTransitionConfig","outTransition","outTransitionConfig","asChild","id"];let o=compute_rest_props(e,r),s,l,{$$slots:c={},$$scope:f}=e,{transition:h=void 0}=e,{transitionConfig:u=void 0}=e,{inTransition:i=void 0}=e,{inTransitionConfig:d=void 0}=e,{outTransition:p=void 0}=e,{outTransitionConfig:_=void 0}=e,{asChild:m=!1}=e,{id:g=void 0}=e;const{elements:{content:b},states:{open:v},ids:T}=getCtx$1();component_subscribe(a,b,w=>n(14,s=w)),component_subscribe(a,v,w=>n(8,l=w));const y=getAttrs$1("content");return a.$$set=w=>{e=assign(assign({},e),exclude_internal_props(w)),n(12,o=compute_rest_props(e,r)),"transition"in w&&n(0,h=w.transition),"transitionConfig"in w&&n(1,u=w.transitionConfig),"inTransition"in w&&n(2,i=w.inTransition),"inTransitionConfig"in w&&n(3,d=w.inTransitionConfig),"outTransition"in w&&n(4,p=w.outTransition),"outTransitionConfig"in w&&n(5,_=w.outTransitionConfig),"asChild"in w&&n(6,m=w.asChild),"id"in w&&n(13,g=w.id),"$$scope"in w&&n(15,f=w.$$scope)},a.$$.update=()=>{a.$$.dirty&8192&&g&&T.content.set(g),a.$$.dirty&16384&&n(7,t=s)},[h,u,i,d,p,_,m,t,l,b,v,y,o,g,s,f,c]}class PopoverContent extends SvelteComponent{constructor(e){super(),init(this,e,instance$1u,create_fragment$1q,safe_not_equal,{transition:0,transitionConfig:1,inTransition:2,inTransitionConfig:3,outTransition:4,outTransitionConfig:5,asChild:6,id:13})}}const get_default_slot_changes_1$9=a=>({builder:a&2}),get_default_slot_context_1$9=a=>({builder:a[1],attrs:a[4]}),get_default_slot_changes$e=a=>({builder:a&2}),get_default_slot_context$e=a=>({builder:a[1],attrs:a[4]});function create_else_block$m(a){let e,n,t,r;const o=a[9].default,s=create_slot(o,a,a[8],get_default_slot_context_1$9);let l=[a[1],{type:"button"},a[5],a[4]],c={};for(let f=0;f<l.length;f+=1)c=assign(c,l[f]);return{c(){e=element("button"),s&&s.c(),this.h()},l(f){e=claim_element(f,"BUTTON",{type:!0});var h=children(e);s&&s.l(h),h.forEach(detach),this.h()},h(){set_attributes(e,c)},m(f,h){insert_hydration(f,e,h),s&&s.m(e,null),e.autofocus&&e.focus(),n=!0,t||(r=[action_destroyer(a[1].action(e)),listen(e,"m-click",a[3]),listen(e,"m-keydown",a[3])],t=!0)},p(f,h){s&&s.p&&(!n||h&258)&&update_slot_base(s,o,f,f[8],n?get_slot_changes(o,f[8],h,get_default_slot_changes_1$9):get_all_dirty_from_scope(f[8]),get_default_slot_context_1$9),set_attributes(e,c=get_spread_update(l,[h&2&&f[1],{type:"button"},h&32&&f[5],f[4]]))},i(f){n||(transition_in(s,f),n=!0)},o(f){transition_out(s,f),n=!1},d(f){f&&detach(e),s&&s.d(f),t=!1,run_all(r)}}}function create_if_block$G(a){let e;const n=a[9].default,t=create_slot(n,a,a[8],get_default_slot_context$e);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&258)&&update_slot_base(t,n,r,r[8],e?get_slot_changes(n,r[8],o,get_default_slot_changes$e):get_all_dirty_from_scope(r[8]),get_default_slot_context$e)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$1p(a){let e,n,t,r;const o=[create_if_block$G,create_else_block$m],s=[];function l(c,f){return c[0]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){let h=e;e=l(c),e===h?s[e].p(c,f):(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function instance$1t(a,e,n){let t;const r=["asChild","id"];let o=compute_rest_props(e,r),s,{$$slots:l={},$$scope:c}=e,{asChild:f=!1}=e,{id:h=void 0}=e;const{elements:{trigger:u},ids:i}=getCtx$1();component_subscribe(a,u,_=>n(7,s=_));const d=createDispatcher(),p=getAttrs$1("trigger");return a.$$set=_=>{e=assign(assign({},e),exclude_internal_props(_)),n(5,o=compute_rest_props(e,r)),"asChild"in _&&n(0,f=_.asChild),"id"in _&&n(6,h=_.id),"$$scope"in _&&n(8,c=_.$$scope)},a.$$.update=()=>{a.$$.dirty&64&&h&&i.trigger.set(h),a.$$.dirty&128&&n(1,t=s)},[f,t,u,d,p,o,h,s,c,l]}class PopoverTrigger extends SvelteComponent{constructor(e){super(),init(this,e,instance$1t,create_fragment$1p,safe_not_equal,{asChild:0,id:6})}}const get_default_slot_changes_1$8=a=>({builder:a&2,ticks:a&4}),get_default_slot_context_1$8=a=>({builder:a[1],attrs:a[5],ticks:a[2]}),get_default_slot_changes$d=a=>({builder:a&2,ticks:a&4}),get_default_slot_context$d=a=>({builder:a[1],attrs:a[5],ticks:a[2]});function create_else_block$l(a){let e,n,t,r;const o=a[16].default,s=create_slot(o,a,a[15],get_default_slot_context_1$8);let l=[a[1],a[6],a[5]],c={};for(let f=0;f<l.length;f+=1)c=assign(c,l[f]);return{c(){e=element("span"),s&&s.c(),this.h()},l(f){e=claim_element(f,"SPAN",{});var h=children(e);s&&s.l(h),h.forEach(detach),this.h()},h(){set_attributes(e,c)},m(f,h){insert_hydration(f,e,h),s&&s.m(e,null),n=!0,t||(r=action_destroyer(a[1].action(e)),t=!0)},p(f,h){s&&s.p&&(!n||h&32774)&&update_slot_base(s,o,f,f[15],n?get_slot_changes(o,f[15],h,get_default_slot_changes_1$8):get_all_dirty_from_scope(f[15]),get_default_slot_context_1$8),set_attributes(e,c=get_spread_update(l,[h&2&&f[1],h&64&&f[6],f[5]]))},i(f){n||(transition_in(s,f),n=!0)},o(f){transition_out(s,f),n=!1},d(f){f&&detach(e),s&&s.d(f),t=!1,r()}}}function create_if_block$F(a){let e;const n=a[16].default,t=create_slot(n,a,a[15],get_default_slot_context$d);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&32774)&&update_slot_base(t,n,r,r[15],e?get_slot_changes(n,r[15],o,get_default_slot_changes$d):get_all_dirty_from_scope(r[15]),get_default_slot_context$d)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$1o(a){let e,n,t,r;const o=[create_if_block$F,create_else_block$l],s=[];function l(c,f){return c[0]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){let h=e;e=l(c),e===h?s[e].p(c,f):(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function instance$1s(a,e,n){let t;const r=["disabled","min","max","step","orientation","value","onValueChange","asChild"];let o=compute_rest_props(e,r),s,l,{$$slots:c={},$$scope:f}=e,{disabled:h=void 0}=e,{min:u=void 0}=e,{max:i=void 0}=e,{step:d=void 0}=e,{orientation:p=void 0}=e,{value:_=void 0}=e,{onValueChange:m=void 0}=e,{asChild:g=!1}=e;const{elements:{root:b},states:{value:v,ticks:T},updateOption:y}=setCtx$2({disabled:h,min:u,max:i,step:d,orientation:p,defaultValue:_,onValueChange:({next:S})=>(_!==S&&(m==null||m(S),n(7,_=S)),S)});component_subscribe(a,b,S=>n(14,s=S)),component_subscribe(a,T,S=>n(2,l=S));const w=getAttrs$2("root");return a.$$set=S=>{e=assign(assign({},e),exclude_internal_props(S)),n(6,o=compute_rest_props(e,r)),"disabled"in S&&n(8,h=S.disabled),"min"in S&&n(9,u=S.min),"max"in S&&n(10,i=S.max),"step"in S&&n(11,d=S.step),"orientation"in S&&n(12,p=S.orientation),"value"in S&&n(7,_=S.value),"onValueChange"in S&&n(13,m=S.onValueChange),"asChild"in S&&n(0,g=S.asChild),"$$scope"in S&&n(15,f=S.$$scope)},a.$$.update=()=>{a.$$.dirty&128&&_!==void 0&&v.set(_),a.$$.dirty&256&&y("disabled",h),a.$$.dirty&512&&y("min",u),a.$$.dirty&1024&&y("max",i),a.$$.dirty&2048&&y("step",d),a.$$.dirty&4096&&y("orientation",p),a.$$.dirty&16384&&n(1,t=s)},[g,t,l,b,T,w,o,_,h,u,i,d,p,m,s,f,c]}class Slider extends SvelteComponent{constructor(e){super(),init(this,e,instance$1s,create_fragment$1o,safe_not_equal,{disabled:8,min:9,max:10,step:11,orientation:12,value:7,onValueChange:13,asChild:0})}}const get_default_slot_changes$c=a=>({builder:a&2}),get_default_slot_context$c=a=>({builder:a[1],attrs:a[3]});function create_else_block$k(a){let e,n,t,r=[a[1],a[4],a[3]],o={};for(let s=0;s<r.length;s+=1)o=assign(o,r[s]);return{c(){e=element("span"),this.h()},l(s){e=claim_element(s,"SPAN",{}),children(e).forEach(detach),this.h()},h(){set_attributes(e,o)},m(s,l){insert_hydration(s,e,l),n||(t=action_destroyer(a[1].action(e)),n=!0)},p(s,l){set_attributes(e,o=get_spread_update(r,[l&2&&s[1],l&16&&s[4],s[3]]))},i:noop,o:noop,d(s){s&&detach(e),n=!1,t()}}}function create_if_block$E(a){let e;const n=a[7].default,t=create_slot(n,a,a[6],get_default_slot_context$c);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&66)&&update_slot_base(t,n,r,r[6],e?get_slot_changes(n,r[6],o,get_default_slot_changes$c):get_all_dirty_from_scope(r[6]),get_default_slot_context$c)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$1n(a){let e,n,t,r;const o=[create_if_block$E,create_else_block$k],s=[];function l(c,f){return c[0]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){let h=e;e=l(c),e===h?s[e].p(c,f):(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function instance$1r(a,e,n){let t;const r=["asChild"];let o=compute_rest_props(e,r),s,{$$slots:l={},$$scope:c}=e,{asChild:f=!1}=e;const{elements:{range:h}}=getCtx$2();component_subscribe(a,h,i=>n(5,s=i));const u=getAttrs$2("range");return a.$$set=i=>{e=assign(assign({},e),exclude_internal_props(i)),n(4,o=compute_rest_props(e,r)),"asChild"in i&&n(0,f=i.asChild),"$$scope"in i&&n(6,c=i.$$scope)},a.$$.update=()=>{a.$$.dirty&32&&n(1,t=s)},[f,t,h,u,o,s,c,l]}class SliderRange extends SvelteComponent{constructor(e){super(),init(this,e,instance$1r,create_fragment$1n,safe_not_equal,{asChild:0})}}const get_default_slot_changes$b=a=>({builder:a&2}),get_default_slot_context$b=a=>({builder:a[1],attrs:a[4]});function create_else_block$j(a){let e,n,t,r=[a[1],a[5],a[4]],o={};for(let s=0;s<r.length;s+=1)o=assign(o,r[s]);return{c(){e=element("span"),this.h()},l(s){e=claim_element(s,"SPAN",{}),children(e).forEach(detach),this.h()},h(){set_attributes(e,o)},m(s,l){insert_hydration(s,e,l),n||(t=[action_destroyer(a[1].action(e)),listen(e,"m-keydown",a[3])],n=!0)},p(s,l){set_attributes(e,o=get_spread_update(r,[l&2&&s[1],l&32&&s[5],s[4]]))},i:noop,o:noop,d(s){s&&detach(e),n=!1,run_all(t)}}}function create_if_block$D(a){let e;const n=a[8].default,t=create_slot(n,a,a[7],get_default_slot_context$b);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&130)&&update_slot_base(t,n,r,r[7],e?get_slot_changes(n,r[7],o,get_default_slot_changes$b):get_all_dirty_from_scope(r[7]),get_default_slot_context$b)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$1m(a){let e,n,t,r;const o=[create_if_block$D,create_else_block$j],s=[];function l(c,f){return c[0]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){let h=e;e=l(c),e===h?s[e].p(c,f):(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function instance$1q(a,e,n){let t;const r=["asChild"];let o=compute_rest_props(e,r),s,{$$slots:l={},$$scope:c}=e,{asChild:f=!1}=e;const{elements:{thumb:h}}=getCtx$2();component_subscribe(a,h,d=>n(6,s=d));const u=createDispatcher(),i=getAttrs$2("thumb");return a.$$set=d=>{e=assign(assign({},e),exclude_internal_props(d)),n(5,o=compute_rest_props(e,r)),"asChild"in d&&n(0,f=d.asChild),"$$scope"in d&&n(7,c=d.$$scope)},a.$$.update=()=>{a.$$.dirty&64&&n(1,t=s())},[f,t,h,u,i,o,s,c,l]}class SliderThumb extends SvelteComponent{constructor(e){super(),init(this,e,instance$1q,create_fragment$1m,safe_not_equal,{asChild:0})}}function create_fragment$1l(a){let e,n,t,r=[a[1],{name:a[2]},{disabled:a[3]},{required:a[4]},{value:a[0]},a[10]],o={};for(let s=0;s<r.length;s+=1)o=assign(o,r[s]);return{c(){e=element("input"),this.h()},l(s){e=claim_element(s,"INPUT",{name:!0}),this.h()},h(){set_attributes(e,o)},m(s,l){insert_hydration(s,e,l),"value"in o&&(e.value=o.value),e.autofocus&&e.focus(),n||(t=action_destroyer(a[1].action(e)),n=!0)},p(s,[l]){set_attributes(e,o=get_spread_update(r,[l&2&&s[1],l&4&&{name:s[2]},l&8&&{disabled:s[3]},l&16&&{required:s[4]},l&1&&e.value!==s[0]&&{value:s[0]},l&1024&&s[10]])),"value"in o&&(e.value=o.value)},i:noop,o:noop,d(s){s&&detach(e),n=!1,t()}}}function instance$1p(a,e,n){let t;const r=[];let o=compute_rest_props(e,r),s,l,c,f,h;const{elements:{input:u},options:{value:i,name:d,disabled:p,required:_}}=getCtx$3();return component_subscribe(a,u,m=>n(1,l=m)),component_subscribe(a,i,m=>n(11,s=m)),component_subscribe(a,d,m=>n(2,c=m)),component_subscribe(a,p,m=>n(3,f=m)),component_subscribe(a,_,m=>n(4,h=m)),a.$$set=m=>{e=assign(assign({},e),exclude_internal_props(m)),n(10,o=compute_rest_props(e,r))},a.$$.update=()=>{a.$$.dirty&2048&&n(0,t=s===void 0||s===""?"on":s)},[t,l,c,f,h,u,i,d,p,_,o,s]}class SwitchInput extends SvelteComponent{constructor(e){super(),init(this,e,instance$1p,create_fragment$1l,safe_not_equal,{})}}const get_default_slot_changes_1$7=a=>({builder:a&16,attrs:a&8}),get_default_slot_context_1$7=a=>({builder:a[4],attrs:a[3]}),get_default_slot_changes$a=a=>({builder:a&16,attrs:a&8}),get_default_slot_context$a=a=>({builder:a[4],attrs:a[3]});function create_else_block$i(a){let e,n,t,r;const o=a[16].default,s=create_slot(o,a,a[15],get_default_slot_context_1$7);let l=[a[4],{type:"button"},a[7],a[3]],c={};for(let f=0;f<l.length;f+=1)c=assign(c,l[f]);return{c(){e=element("button"),s&&s.c(),this.h()},l(f){e=claim_element(f,"BUTTON",{type:!0});var h=children(e);s&&s.l(h),h.forEach(detach),this.h()},h(){set_attributes(e,c)},m(f,h){insert_hydration(f,e,h),s&&s.m(e,null),e.autofocus&&e.focus(),n=!0,t||(r=[action_destroyer(a[4].action(e)),listen(e,"m-click",a[6]),listen(e,"m-keydown",a[6])],t=!0)},p(f,h){s&&s.p&&(!n||h&32792)&&update_slot_base(s,o,f,f[15],n?get_slot_changes(o,f[15],h,get_default_slot_changes_1$7):get_all_dirty_from_scope(f[15]),get_default_slot_context_1$7),set_attributes(e,c=get_spread_update(l,[h&16&&f[4],{type:"button"},h&128&&f[7],h&8&&f[3]]))},i(f){n||(transition_in(s,f),n=!0)},o(f){transition_out(s,f),n=!1},d(f){f&&detach(e),s&&s.d(f),t=!1,run_all(r)}}}function create_if_block_1$h(a){let e;const n=a[16].default,t=create_slot(n,a,a[15],get_default_slot_context$a);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&32792)&&update_slot_base(t,n,r,r[15],e?get_slot_changes(n,r[15],o,get_default_slot_changes$a):get_all_dirty_from_scope(r[15]),get_default_slot_context$a)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_if_block$C(a){let e,n;const t=[a[2]];let r={};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new SwitchInput({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,s){const l=s&4?get_spread_update(t,[get_spread_object(o[2])]):{};e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function create_fragment$1k(a){let e,n,t,r,o;const s=[create_if_block_1$h,create_else_block$i],l=[];function c(h,u){return h[1]?0:1}e=c(a),n=l[e]=s[e](a);let f=a[0]&&create_if_block$C(a);return{c(){n.c(),t=space(),f&&f.c(),r=empty()},l(h){n.l(h),t=claim_space(h),f&&f.l(h),r=empty()},m(h,u){l[e].m(h,u),insert_hydration(h,t,u),f&&f.m(h,u),insert_hydration(h,r,u),o=!0},p(h,[u]){let i=e;e=c(h),e===i?l[e].p(h,u):(group_outros(),transition_out(l[i],1,1,()=>{l[i]=null}),check_outros(),n=l[e],n?n.p(h,u):(n=l[e]=s[e](h),n.c()),transition_in(n,1),n.m(t.parentNode,t)),h[0]?f?(f.p(h,u),u&1&&transition_in(f,1)):(f=create_if_block$C(h),f.c(),transition_in(f,1),f.m(r.parentNode,r)):f&&(group_outros(),transition_out(f,1,1,()=>{f=null}),check_outros())},i(h){o||(transition_in(n),transition_in(f),o=!0)},o(h){transition_out(n),transition_out(f),o=!1},d(h){h&&(detach(t),detach(r)),l[e].d(h),f&&f.d(h)}}}function instance$1o(a,e,n){let t,r;const o=["checked","onCheckedChange","disabled","name","value","includeInput","required","asChild","inputAttrs"];let s=compute_rest_props(e,o),l,{$$slots:c={},$$scope:f}=e,{checked:h=void 0}=e,{onCheckedChange:u=void 0}=e,{disabled:i=void 0}=e,{name:d=void 0}=e,{value:p=void 0}=e,{includeInput:_=!0}=e,{required:m=void 0}=e,{asChild:g=!1}=e,{inputAttrs:b=void 0}=e;const{elements:{root:v},states:{checked:T},updateOption:y}=setCtx$3({disabled:i,name:d,value:p,required:m,defaultChecked:h,onCheckedChange:({next:S})=>(h!==S&&(u==null||u(S),n(8,h=S)),S)});component_subscribe(a,v,S=>n(14,l=S));const w=createDispatcher();return a.$$set=S=>{e=assign(assign({},e),exclude_internal_props(S)),n(7,s=compute_rest_props(e,o)),"checked"in S&&n(8,h=S.checked),"onCheckedChange"in S&&n(9,u=S.onCheckedChange),"disabled"in S&&n(10,i=S.disabled),"name"in S&&n(11,d=S.name),"value"in S&&n(12,p=S.value),"includeInput"in S&&n(0,_=S.includeInput),"required"in S&&n(13,m=S.required),"asChild"in S&&n(1,g=S.asChild),"inputAttrs"in S&&n(2,b=S.inputAttrs),"$$scope"in S&&n(15,f=S.$$scope)},a.$$.update=()=>{a.$$.dirty&256&&h!==void 0&&T.set(h),a.$$.dirty&1024&&y("disabled",i),a.$$.dirty&2048&&y("name",d),a.$$.dirty&4096&&y("value",p),a.$$.dirty&8192&&y("required",m),a.$$.dirty&16384&&n(4,t=l),a.$$.dirty&256&&n(3,r={...getAttrs$3("root"),"data-checked":h?"":void 0})},[_,g,b,r,t,v,w,s,h,u,i,d,p,m,l,f,c]}class Switch extends SvelteComponent{constructor(e){super(),init(this,e,instance$1o,create_fragment$1k,safe_not_equal,{checked:8,onCheckedChange:9,disabled:10,name:11,value:12,includeInput:0,required:13,asChild:1,inputAttrs:2})}}const get_default_slot_changes$9=a=>({checked:a&2,attrs:a&4}),get_default_slot_context$9=a=>({checked:a[1],attrs:a[2]});function create_else_block$h(a){let e,n=[a[4],a[2]],t={};for(let r=0;r<n.length;r+=1)t=assign(t,n[r]);return{c(){e=element("span"),this.h()},l(r){e=claim_element(r,"SPAN",{}),children(e).forEach(detach),this.h()},h(){set_attributes(e,t)},m(r,o){insert_hydration(r,e,o)},p(r,o){set_attributes(e,t=get_spread_update(n,[o&16&&r[4],o&4&&r[2]]))},i:noop,o:noop,d(r){r&&detach(e)}}}function create_if_block$B(a){let e;const n=a[6].default,t=create_slot(n,a,a[5],get_default_slot_context$9);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&38)&&update_slot_base(t,n,r,r[5],e?get_slot_changes(n,r[5],o,get_default_slot_changes$9):get_all_dirty_from_scope(r[5]),get_default_slot_context$9)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$1j(a){let e,n,t,r;const o=[create_if_block$B,create_else_block$h],s=[];function l(c,f){return c[0]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){let h=e;e=l(c),e===h?s[e].p(c,f):(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function instance$1n(a,e,n){let t;const r=["asChild"];let o=compute_rest_props(e,r),s,{$$slots:l={},$$scope:c}=e,{asChild:f=!1}=e;const{states:{checked:h}}=getCtx$3();return component_subscribe(a,h,u=>n(1,s=u)),a.$$set=u=>{e=assign(assign({},e),exclude_internal_props(u)),n(4,o=compute_rest_props(e,r)),"asChild"in u&&n(0,f=u.asChild),"$$scope"in u&&n(5,c=u.$$scope)},a.$$.update=()=>{a.$$.dirty&2&&n(2,t={...getAttrs$3("thumb"),"data-state":s?"checked":"unchecked","data-checked":s?"":void 0})},[f,s,t,h,o,c,l]}class SwitchThumb extends SvelteComponent{constructor(e){super(),init(this,e,instance$1n,create_fragment$1j,safe_not_equal,{asChild:0})}}const get_default_slot_changes_1$6=a=>({builder:a&2}),get_default_slot_context_1$6=a=>({builder:a[1],attrs:a[3]}),get_default_slot_changes$8=a=>({builder:a&2}),get_default_slot_context$8=a=>({builder:a[1],attrs:a[3]});function create_else_block$g(a){let e,n,t,r;const o=a[13].default,s=create_slot(o,a,a[12],get_default_slot_context_1$6);let l=[a[1],a[4],a[3]],c={};for(let f=0;f<l.length;f+=1)c=assign(c,l[f]);return{c(){e=element("div"),s&&s.c(),this.h()},l(f){e=claim_element(f,"DIV",{});var h=children(e);s&&s.l(h),h.forEach(detach),this.h()},h(){set_attributes(e,c)},m(f,h){insert_hydration(f,e,h),s&&s.m(e,null),n=!0,t||(r=action_destroyer(a[1].action(e)),t=!0)},p(f,h){s&&s.p&&(!n||h&4098)&&update_slot_base(s,o,f,f[12],n?get_slot_changes(o,f[12],h,get_default_slot_changes_1$6):get_all_dirty_from_scope(f[12]),get_default_slot_context_1$6),set_attributes(e,c=get_spread_update(l,[h&2&&f[1],h&16&&f[4],f[3]]))},i(f){n||(transition_in(s,f),n=!0)},o(f){transition_out(s,f),n=!1},d(f){f&&detach(e),s&&s.d(f),t=!1,r()}}}function create_if_block$A(a){let e;const n=a[13].default,t=create_slot(n,a,a[12],get_default_slot_context$8);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&4098)&&update_slot_base(t,n,r,r[12],e?get_slot_changes(n,r[12],o,get_default_slot_changes$8):get_all_dirty_from_scope(r[12]),get_default_slot_context$8)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$1i(a){let e,n,t,r;const o=[create_if_block$A,create_else_block$g],s=[];function l(c,f){return c[0]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){let h=e;e=l(c),e===h?s[e].p(c,f):(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function instance$1m(a,e,n){let t;const r=["orientation","activateOnFocus","loop","autoSet","value","onValueChange","asChild"];let o=compute_rest_props(e,r),s,{$$slots:l={},$$scope:c}=e,{orientation:f=void 0}=e,{activateOnFocus:h=void 0}=e,{loop:u=void 0}=e,{autoSet:i=void 0}=e,{value:d=void 0}=e,{onValueChange:p=void 0}=e,{asChild:_=!1}=e;const{elements:{root:m},states:{value:g},updateOption:b}=setCtx$4({orientation:f,activateOnFocus:h,loop:u,autoSet:i,defaultValue:d,onValueChange:({next:T})=>(d!==T&&(p==null||p(T),n(5,d=T)),T)});component_subscribe(a,m,T=>n(11,s=T));const v=getAttrs$4("root");return a.$$set=T=>{e=assign(assign({},e),exclude_internal_props(T)),n(4,o=compute_rest_props(e,r)),"orientation"in T&&n(6,f=T.orientation),"activateOnFocus"in T&&n(7,h=T.activateOnFocus),"loop"in T&&n(8,u=T.loop),"autoSet"in T&&n(9,i=T.autoSet),"value"in T&&n(5,d=T.value),"onValueChange"in T&&n(10,p=T.onValueChange),"asChild"in T&&n(0,_=T.asChild),"$$scope"in T&&n(12,c=T.$$scope)},a.$$.update=()=>{a.$$.dirty&32&&d!==void 0&&g.set(d),a.$$.dirty&64&&b("orientation",f),a.$$.dirty&128&&b("activateOnFocus",h),a.$$.dirty&256&&b("loop",u),a.$$.dirty&512&&b("autoSet",i),a.$$.dirty&2048&&n(1,t=s)},[_,t,m,v,o,d,f,h,u,i,p,s,c,l]}class Tabs extends SvelteComponent{constructor(e){super(),init(this,e,instance$1m,create_fragment$1i,safe_not_equal,{orientation:6,activateOnFocus:7,loop:8,autoSet:9,value:5,onValueChange:10,asChild:0})}}const get_default_slot_changes_1$5=a=>({builder:a&2}),get_default_slot_context_1$5=a=>({builder:a[1],attrs:a[3]}),get_default_slot_changes$7=a=>({builder:a&2}),get_default_slot_context$7=a=>({builder:a[1],attrs:a[3]});function create_else_block$f(a){let e,n,t,r;const o=a[8].default,s=create_slot(o,a,a[7],get_default_slot_context_1$5);let l=[a[1],a[4],a[3]],c={};for(let f=0;f<l.length;f+=1)c=assign(c,l[f]);return{c(){e=element("div"),s&&s.c(),this.h()},l(f){e=claim_element(f,"DIV",{});var h=children(e);s&&s.l(h),h.forEach(detach),this.h()},h(){set_attributes(e,c)},m(f,h){insert_hydration(f,e,h),s&&s.m(e,null),n=!0,t||(r=action_destroyer(a[1].action(e)),t=!0)},p(f,h){s&&s.p&&(!n||h&130)&&update_slot_base(s,o,f,f[7],n?get_slot_changes(o,f[7],h,get_default_slot_changes_1$5):get_all_dirty_from_scope(f[7]),get_default_slot_context_1$5),set_attributes(e,c=get_spread_update(l,[h&2&&f[1],h&16&&f[4],f[3]]))},i(f){n||(transition_in(s,f),n=!0)},o(f){transition_out(s,f),n=!1},d(f){f&&detach(e),s&&s.d(f),t=!1,r()}}}function create_if_block$z(a){let e;const n=a[8].default,t=create_slot(n,a,a[7],get_default_slot_context$7);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&130)&&update_slot_base(t,n,r,r[7],e?get_slot_changes(n,r[7],o,get_default_slot_changes$7):get_all_dirty_from_scope(r[7]),get_default_slot_context$7)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$1h(a){let e,n,t,r;const o=[create_if_block$z,create_else_block$f],s=[];function l(c,f){return c[0]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){let h=e;e=l(c),e===h?s[e].p(c,f):(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function instance$1l(a,e,n){let t;const r=["value","asChild"];let o=compute_rest_props(e,r),s,{$$slots:l={},$$scope:c}=e,{value:f}=e,{asChild:h=!1}=e;const{elements:{content:u}}=getCtx$4();component_subscribe(a,u,d=>n(6,s=d));const i=getAttrs$4("content");return a.$$set=d=>{e=assign(assign({},e),exclude_internal_props(d)),n(4,o=compute_rest_props(e,r)),"value"in d&&n(5,f=d.value),"asChild"in d&&n(0,h=d.asChild),"$$scope"in d&&n(7,c=d.$$scope)},a.$$.update=()=>{a.$$.dirty&96&&n(1,t=s(f))},[h,t,u,i,o,f,s,c,l]}class TabsContent extends SvelteComponent{constructor(e){super(),init(this,e,instance$1l,create_fragment$1h,safe_not_equal,{value:5,asChild:0})}}const get_default_slot_changes_1$4=a=>({builder:a&2}),get_default_slot_context_1$4=a=>({builder:a[1],attrs:a[3]}),get_default_slot_changes$6=a=>({builder:a&2}),get_default_slot_context$6=a=>({builder:a[1],attrs:a[3]});function create_else_block$e(a){let e,n,t,r;const o=a[7].default,s=create_slot(o,a,a[6],get_default_slot_context_1$4);let l=[a[1],a[4],a[3]],c={};for(let f=0;f<l.length;f+=1)c=assign(c,l[f]);return{c(){e=element("div"),s&&s.c(),this.h()},l(f){e=claim_element(f,"DIV",{});var h=children(e);s&&s.l(h),h.forEach(detach),this.h()},h(){set_attributes(e,c)},m(f,h){insert_hydration(f,e,h),s&&s.m(e,null),n=!0,t||(r=action_destroyer(a[1].action(e)),t=!0)},p(f,h){s&&s.p&&(!n||h&66)&&update_slot_base(s,o,f,f[6],n?get_slot_changes(o,f[6],h,get_default_slot_changes_1$4):get_all_dirty_from_scope(f[6]),get_default_slot_context_1$4),set_attributes(e,c=get_spread_update(l,[h&2&&f[1],h&16&&f[4],f[3]]))},i(f){n||(transition_in(s,f),n=!0)},o(f){transition_out(s,f),n=!1},d(f){f&&detach(e),s&&s.d(f),t=!1,r()}}}function create_if_block$y(a){let e;const n=a[7].default,t=create_slot(n,a,a[6],get_default_slot_context$6);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&66)&&update_slot_base(t,n,r,r[6],e?get_slot_changes(n,r[6],o,get_default_slot_changes$6):get_all_dirty_from_scope(r[6]),get_default_slot_context$6)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$1g(a){let e,n,t,r;const o=[create_if_block$y,create_else_block$e],s=[];function l(c,f){return c[0]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){let h=e;e=l(c),e===h?s[e].p(c,f):(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function instance$1k(a,e,n){let t;const r=["asChild"];let o=compute_rest_props(e,r),s,{$$slots:l={},$$scope:c}=e,{asChild:f=!1}=e;const{elements:{list:h}}=getCtx$4();component_subscribe(a,h,i=>n(5,s=i));const u=getAttrs$4("list");return a.$$set=i=>{e=assign(assign({},e),exclude_internal_props(i)),n(4,o=compute_rest_props(e,r)),"asChild"in i&&n(0,f=i.asChild),"$$scope"in i&&n(6,c=i.$$scope)},a.$$.update=()=>{a.$$.dirty&32&&n(1,t=s)},[f,t,h,u,o,s,c,l]}class TabsList extends SvelteComponent{constructor(e){super(),init(this,e,instance$1k,create_fragment$1g,safe_not_equal,{asChild:0})}}const get_default_slot_changes_1$3=a=>({builder:a&2}),get_default_slot_context_1$3=a=>({builder:a[1],attrs:a[4]}),get_default_slot_changes$5=a=>({builder:a&2}),get_default_slot_context$5=a=>({builder:a[1],attrs:a[4]});function create_else_block$d(a){let e,n,t,r;const o=a[10].default,s=create_slot(o,a,a[9],get_default_slot_context_1$3);let l=[a[1],{type:"button"},a[5],a[4]],c={};for(let f=0;f<l.length;f+=1)c=assign(c,l[f]);return{c(){e=element("button"),s&&s.c(),this.h()},l(f){e=claim_element(f,"BUTTON",{type:!0});var h=children(e);s&&s.l(h),h.forEach(detach),this.h()},h(){set_attributes(e,c)},m(f,h){insert_hydration(f,e,h),s&&s.m(e,null),e.autofocus&&e.focus(),n=!0,t||(r=[action_destroyer(a[1].action(e)),listen(e,"m-click",a[3]),listen(e,"m-focus",a[3]),listen(e,"m-keydown",a[3])],t=!0)},p(f,h){s&&s.p&&(!n||h&514)&&update_slot_base(s,o,f,f[9],n?get_slot_changes(o,f[9],h,get_default_slot_changes_1$3):get_all_dirty_from_scope(f[9]),get_default_slot_context_1$3),set_attributes(e,c=get_spread_update(l,[h&2&&f[1],{type:"button"},h&32&&f[5],f[4]]))},i(f){n||(transition_in(s,f),n=!0)},o(f){transition_out(s,f),n=!1},d(f){f&&detach(e),s&&s.d(f),t=!1,run_all(r)}}}function create_if_block$x(a){let e;const n=a[10].default,t=create_slot(n,a,a[9],get_default_slot_context$5);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&514)&&update_slot_base(t,n,r,r[9],e?get_slot_changes(n,r[9],o,get_default_slot_changes$5):get_all_dirty_from_scope(r[9]),get_default_slot_context$5)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$1f(a){let e,n,t,r;const o=[create_if_block$x,create_else_block$d],s=[];function l(c,f){return c[0]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){let h=e;e=l(c),e===h?s[e].p(c,f):(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function instance$1j(a,e,n){let t;const r=["value","disabled","asChild"];let o=compute_rest_props(e,r),s,{$$slots:l={},$$scope:c}=e,{value:f}=e,{disabled:h=void 0}=e,{asChild:u=!1}=e;const{elements:{trigger:i}}=getCtx$4();component_subscribe(a,i,_=>n(8,s=_));const d=createDispatcher(),p=getAttrs$4("trigger");return a.$$set=_=>{e=assign(assign({},e),exclude_internal_props(_)),n(5,o=compute_rest_props(e,r)),"value"in _&&n(6,f=_.value),"disabled"in _&&n(7,h=_.disabled),"asChild"in _&&n(0,u=_.asChild),"$$scope"in _&&n(9,c=_.$$scope)},a.$$.update=()=>{a.$$.dirty&448&&n(1,t=s({value:f,disabled:h}))},[u,t,i,d,p,o,f,h,s,c,l]}class TabsTrigger extends SvelteComponent{constructor(e){super(),init(this,e,instance$1j,create_fragment$1f,safe_not_equal,{value:6,disabled:7,asChild:0})}}function create_default_slot$O(a){let e;const n=a[3].default,t=create_slot(n,a,a[4],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&16)&&update_slot_base(t,n,r,r[4],e?get_slot_changes(n,r[4],o,null):get_all_dirty_from_scope(r[4]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$1e(a){let e,n;const t=[{class:cn("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",a[0])},{value:a[1]},a[2]];let r={$$slots:{default:[create_default_slot$O]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new TabsContent({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&7?get_spread_update(t,[s&1&&{class:cn("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",o[0])},s&2&&{value:o[1]},s&4&&get_spread_object(o[2])]):{};s&16&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$1i(a,e,n){const t=["class","value"];let r=compute_rest_props(e,t),{$$slots:o={},$$scope:s}=e,{class:l=void 0}=e,{value:c}=e;return a.$$set=f=>{e=assign(assign({},e),exclude_internal_props(f)),n(2,r=compute_rest_props(e,t)),"class"in f&&n(0,l=f.class),"value"in f&&n(1,c=f.value),"$$scope"in f&&n(4,s=f.$$scope)},[l,c,r,o,s]}class Tabs_content extends SvelteComponent{constructor(e){super(),init(this,e,instance$1i,create_fragment$1e,safe_not_equal,{class:0,value:1})}}function create_default_slot$N(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$1d(a){let e,n;const t=[{class:cn("inline-flex w-full h-10 items-center justify-center text-muted-foreground",a[0])},a[1]];let r={$$slots:{default:[create_default_slot$N]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new TabsList({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[s&1&&{class:cn("inline-flex w-full h-10 items-center justify-center text-muted-foreground",o[0])},s&2&&get_spread_object(o[1])]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$1h(a,e,n){const t=["class"];let r=compute_rest_props(e,t),{$$slots:o={},$$scope:s}=e,{class:l=void 0}=e;return a.$$set=c=>{e=assign(assign({},e),exclude_internal_props(c)),n(1,r=compute_rest_props(e,t)),"class"in c&&n(0,l=c.class),"$$scope"in c&&n(3,s=c.$$scope)},[l,r,o,s]}class Tabs_list extends SvelteComponent{constructor(e){super(),init(this,e,instance$1h,create_fragment$1d,safe_not_equal,{class:0})}}function create_default_slot$M(a){let e;const n=a[3].default,t=create_slot(n,a,a[5],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&32)&&update_slot_base(t,n,r,r[5],e?get_slot_changes(n,r[5],o,null):get_all_dirty_from_scope(r[5]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$1c(a){let e,n;const t=[{class:cn("inline-flex flex-grow items-center justify-center whitespace-nowrap uppercase font-light text-slate-800 px-3 pt-6 pb-2 ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border-transparent border-b-2 data-[state=inactive]:bg-white data-[state=active]:font-bold",a[0])},{value:a[1]},a[2]];let r={$$slots:{default:[create_default_slot$M]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new TabsTrigger({props:r}),e.$on("click",a[4]),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&7?get_spread_update(t,[s&1&&{class:cn("inline-flex flex-grow items-center justify-center whitespace-nowrap uppercase font-light text-slate-800 px-3 pt-6 pb-2 ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border-transparent border-b-2 data-[state=inactive]:bg-white data-[state=active]:font-bold",o[0])},s&2&&{value:o[1]},s&4&&get_spread_object(o[2])]):{};s&32&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$1g(a,e,n){const t=["class","value"];let r=compute_rest_props(e,t),{$$slots:o={},$$scope:s}=e,{class:l=void 0}=e,{value:c}=e;function f(h){bubble.call(this,a,h)}return a.$$set=h=>{e=assign(assign({},e),exclude_internal_props(h)),n(2,r=compute_rest_props(e,t)),"class"in h&&n(0,l=h.class),"value"in h&&n(1,c=h.value),"$$scope"in h&&n(5,s=h.$$scope)},[l,c,r,o,f,s]}class Tabs_trigger extends SvelteComponent{constructor(e){super(),init(this,e,instance$1g,create_fragment$1c,safe_not_equal,{class:0,value:1})}}const Root$2=Tabs;function create_fragment$1b(a){let e,n,t=[{class:n=cn("animate-pulse rounded-md bg-muted",a[0])},a[1]],r={};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return{c(){e=element("div"),this.h()},l(o){e=claim_element(o,"DIV",{class:!0}),children(e).forEach(detach),this.h()},h(){set_attributes(e,r)},m(o,s){insert_hydration(o,e,s)},p(o,[s]){set_attributes(e,r=get_spread_update(t,[s&1&&n!==(n=cn("animate-pulse rounded-md bg-muted",o[0]))&&{class:n},s&2&&o[1]]))},i:noop,o:noop,d(o){o&&detach(e)}}}function instance$1f(a,e,n){const t=["class"];let r=compute_rest_props(e,t),{class:o=void 0}=e;return a.$$set=s=>{e=assign(assign({},e),exclude_internal_props(s)),n(1,r=compute_rest_props(e,t)),"class"in s&&n(0,o=s.class)},[o,r]}class Skeleton extends SvelteComponent{constructor(e){super(),init(this,e,instance$1f,create_fragment$1b,safe_not_equal,{class:0})}}function create_default_slot$L(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$1a(a){let e,n;const t=[{name:"box-select"},a[1],{iconNode:a[0]}];let r={$$slots:{default:[create_default_slot$L]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[t[0],s&2&&get_spread_object(o[1]),s&1&&{iconNode:o[0]}]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$1e(a,e,n){let{$$slots:t={},$$scope:r}=e;const o=[["path",{d:"M5 3a2 2 0 0 0-2 2"}],["path",{d:"M19 3a2 2 0 0 1 2 2"}],["path",{d:"M21 19a2 2 0 0 1-2 2"}],["path",{d:"M5 21a2 2 0 0 1-2-2"}],["path",{d:"M9 3h1"}],["path",{d:"M9 21h1"}],["path",{d:"M14 3h1"}],["path",{d:"M14 21h1"}],["path",{d:"M3 9v1"}],["path",{d:"M21 9v1"}],["path",{d:"M3 14v1"}],["path",{d:"M21 14v1"}]];return a.$$set=s=>{n(1,e=assign(assign({},e),exclude_internal_props(s))),"$$scope"in s&&n(3,r=s.$$scope)},e=exclude_internal_props(e),[o,e,t,r]}class Box_select extends SvelteComponent{constructor(e){super(),init(this,e,instance$1e,create_fragment$1a,safe_not_equal,{})}}const BoxSelectIcon=Box_select;function create_default_slot$K(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$19(a){let e,n;const t=[{name:"brush"},a[1],{iconNode:a[0]}];let r={$$slots:{default:[create_default_slot$K]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[t[0],s&2&&get_spread_object(o[1]),s&1&&{iconNode:o[0]}]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$1d(a,e,n){let{$$slots:t={},$$scope:r}=e;const o=[["path",{d:"m9.06 11.9 8.07-8.06a2.85 2.85 0 1 1 4.03 4.03l-8.06 8.08"}],["path",{d:"M7.07 14.94c-1.66 0-3 1.35-3 3.02 0 1.33-2.5 1.52-2 2.02 1.08 1.1 2.49 2.02 4 2.02 2.2 0 4-1.8 4-4.04a3.01 3.01 0 0 0-3-3.02z"}]];return a.$$set=s=>{n(1,e=assign(assign({},e),exclude_internal_props(s))),"$$scope"in s&&n(3,r=s.$$scope)},e=exclude_internal_props(e),[o,e,t,r]}class Brush extends SvelteComponent{constructor(e){super(),init(this,e,instance$1d,create_fragment$19,safe_not_equal,{})}}function create_default_slot$J(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$18(a){let e,n;const t=[{name:"check-check"},a[1],{iconNode:a[0]}];let r={$$slots:{default:[create_default_slot$J]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[t[0],s&2&&get_spread_object(o[1]),s&1&&{iconNode:o[0]}]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$1c(a,e,n){let{$$slots:t={},$$scope:r}=e;const o=[["path",{d:"M18 6 7 17l-5-5"}],["path",{d:"m22 10-7.5 7.5L13 16"}]];return a.$$set=s=>{n(1,e=assign(assign({},e),exclude_internal_props(s))),"$$scope"in s&&n(3,r=s.$$scope)},e=exclude_internal_props(e),[o,e,t,r]}class Check_check extends SvelteComponent{constructor(e){super(),init(this,e,instance$1c,create_fragment$18,safe_not_equal,{})}}function create_default_slot$I(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$17(a){let e,n;const t=[{name:"chevron-right"},a[1],{iconNode:a[0]}];let r={$$slots:{default:[create_default_slot$I]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[t[0],s&2&&get_spread_object(o[1]),s&1&&{iconNode:o[0]}]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$1b(a,e,n){let{$$slots:t={},$$scope:r}=e;const o=[["path",{d:"m9 18 6-6-6-6"}]];return a.$$set=s=>{n(1,e=assign(assign({},e),exclude_internal_props(s))),"$$scope"in s&&n(3,r=s.$$scope)},e=exclude_internal_props(e),[o,e,t,r]}class Chevron_right extends SvelteComponent{constructor(e){super(),init(this,e,instance$1b,create_fragment$17,safe_not_equal,{})}}const ChevronRight=Chevron_right;function create_default_slot$H(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$16(a){let e,n;const t=[{name:"chevrons-up-down"},a[1],{iconNode:a[0]}];let r={$$slots:{default:[create_default_slot$H]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[t[0],s&2&&get_spread_object(o[1]),s&1&&{iconNode:o[0]}]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$1a(a,e,n){let{$$slots:t={},$$scope:r}=e;const o=[["path",{d:"m7 15 5 5 5-5"}],["path",{d:"m7 9 5-5 5 5"}]];return a.$$set=s=>{n(1,e=assign(assign({},e),exclude_internal_props(s))),"$$scope"in s&&n(3,r=s.$$scope)},e=exclude_internal_props(e),[o,e,t,r]}class Chevrons_up_down extends SvelteComponent{constructor(e){super(),init(this,e,instance$1a,create_fragment$16,safe_not_equal,{})}}function create_default_slot$G(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$15(a){let e,n;const t=[{name:"eye-off"},a[1],{iconNode:a[0]}];let r={$$slots:{default:[create_default_slot$G]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[t[0],s&2&&get_spread_object(o[1]),s&1&&{iconNode:o[0]}]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$19(a,e,n){let{$$slots:t={},$$scope:r}=e;const o=[["path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24"}],["path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"}],["path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22"}]];return a.$$set=s=>{n(1,e=assign(assign({},e),exclude_internal_props(s))),"$$scope"in s&&n(3,r=s.$$scope)},e=exclude_internal_props(e),[o,e,t,r]}class Eye_off extends SvelteComponent{constructor(e){super(),init(this,e,instance$19,create_fragment$15,safe_not_equal,{})}}function create_default_slot$F(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$14(a){let e,n;const t=[{name:"eye"},a[1],{iconNode:a[0]}];let r={$$slots:{default:[create_default_slot$F]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[t[0],s&2&&get_spread_object(o[1]),s&1&&{iconNode:o[0]}]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$18(a,e,n){let{$$slots:t={},$$scope:r}=e;const o=[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}],["circle",{cx:"12",cy:"12",r:"3"}]];return a.$$set=s=>{n(1,e=assign(assign({},e),exclude_internal_props(s))),"$$scope"in s&&n(3,r=s.$$scope)},e=exclude_internal_props(e),[o,e,t,r]}class Eye extends SvelteComponent{constructor(e){super(),init(this,e,instance$18,create_fragment$14,safe_not_equal,{})}}function create_default_slot$E(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$13(a){let e,n;const t=[{name:"filter"},a[1],{iconNode:a[0]}];let r={$$slots:{default:[create_default_slot$E]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[t[0],s&2&&get_spread_object(o[1]),s&1&&{iconNode:o[0]}]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$17(a,e,n){let{$$slots:t={},$$scope:r}=e;const o=[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"}]];return a.$$set=s=>{n(1,e=assign(assign({},e),exclude_internal_props(s))),"$$scope"in s&&n(3,r=s.$$scope)},e=exclude_internal_props(e),[o,e,t,r]}class Filter extends SvelteComponent{constructor(e){super(),init(this,e,instance$17,create_fragment$13,safe_not_equal,{})}}function create_default_slot$D(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$12(a){let e,n;const t=[{name:"minus-circle"},a[1],{iconNode:a[0]}];let r={$$slots:{default:[create_default_slot$D]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[t[0],s&2&&get_spread_object(o[1]),s&1&&{iconNode:o[0]}]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$16(a,e,n){let{$$slots:t={},$$scope:r}=e;const o=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M8 12h8"}]];return a.$$set=s=>{n(1,e=assign(assign({},e),exclude_internal_props(s))),"$$scope"in s&&n(3,r=s.$$scope)},e=exclude_internal_props(e),[o,e,t,r]}class Minus_circle extends SvelteComponent{constructor(e){super(),init(this,e,instance$16,create_fragment$12,safe_not_equal,{})}}function create_default_slot$C(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$11(a){let e,n;const t=[{name:"mouse-pointer"},a[1],{iconNode:a[0]}];let r={$$slots:{default:[create_default_slot$C]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[t[0],s&2&&get_spread_object(o[1]),s&1&&{iconNode:o[0]}]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$15(a,e,n){let{$$slots:t={},$$scope:r}=e;const o=[["path",{d:"m3 3 7.07 16.97 2.51-7.39 7.39-2.51L3 3z"}],["path",{d:"m13 13 6 6"}]];return a.$$set=s=>{n(1,e=assign(assign({},e),exclude_internal_props(s))),"$$scope"in s&&n(3,r=s.$$scope)},e=exclude_internal_props(e),[o,e,t,r]}class Mouse_pointer extends SvelteComponent{constructor(e){super(),init(this,e,instance$15,create_fragment$11,safe_not_equal,{})}}function create_default_slot$B(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$10(a){let e,n;const t=[{name:"pause"},a[1],{iconNode:a[0]}];let r={$$slots:{default:[create_default_slot$B]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[t[0],s&2&&get_spread_object(o[1]),s&1&&{iconNode:o[0]}]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$14(a,e,n){let{$$slots:t={},$$scope:r}=e;const o=[["rect",{width:"4",height:"16",x:"6",y:"4"}],["rect",{width:"4",height:"16",x:"14",y:"4"}]];return a.$$set=s=>{n(1,e=assign(assign({},e),exclude_internal_props(s))),"$$scope"in s&&n(3,r=s.$$scope)},e=exclude_internal_props(e),[o,e,t,r]}class Pause extends SvelteComponent{constructor(e){super(),init(this,e,instance$14,create_fragment$10,safe_not_equal,{})}}function create_default_slot$A(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$$(a){let e,n;const t=[{name:"pencil"},a[1],{iconNode:a[0]}];let r={$$slots:{default:[create_default_slot$A]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[t[0],s&2&&get_spread_object(o[1]),s&1&&{iconNode:o[0]}]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$13(a,e,n){let{$$slots:t={},$$scope:r}=e;const o=[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}],["path",{d:"m15 5 4 4"}]];return a.$$set=s=>{n(1,e=assign(assign({},e),exclude_internal_props(s))),"$$scope"in s&&n(3,r=s.$$scope)},e=exclude_internal_props(e),[o,e,t,r]}class Pencil extends SvelteComponent{constructor(e){super(),init(this,e,instance$13,create_fragment$$,safe_not_equal,{})}}function create_default_slot$z(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$_(a){let e,n;const t=[{name:"play"},a[1],{iconNode:a[0]}];let r={$$slots:{default:[create_default_slot$z]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[t[0],s&2&&get_spread_object(o[1]),s&1&&{iconNode:o[0]}]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$12(a,e,n){let{$$slots:t={},$$scope:r}=e;const o=[["polygon",{points:"5 3 19 12 5 21 5 3"}]];return a.$$set=s=>{n(1,e=assign(assign({},e),exclude_internal_props(s))),"$$scope"in s&&n(3,r=s.$$scope)},e=exclude_internal_props(e),[o,e,t,r]}class Play extends SvelteComponent{constructor(e){super(),init(this,e,instance$12,create_fragment$_,safe_not_equal,{})}}function create_default_slot$y(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$Z(a){let e,n;const t=[{name:"plus-circle"},a[1],{iconNode:a[0]}];let r={$$slots:{default:[create_default_slot$y]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[t[0],s&2&&get_spread_object(o[1]),s&1&&{iconNode:o[0]}]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$11(a,e,n){let{$$slots:t={},$$scope:r}=e;const o=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M8 12h8"}],["path",{d:"M12 8v8"}]];return a.$$set=s=>{n(1,e=assign(assign({},e),exclude_internal_props(s))),"$$scope"in s&&n(3,r=s.$$scope)},e=exclude_internal_props(e),[o,e,t,r]}class Plus_circle extends SvelteComponent{constructor(e){super(),init(this,e,instance$11,create_fragment$Z,safe_not_equal,{})}}function create_default_slot$x(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$Y(a){let e,n;const t=[{name:"search"},a[1],{iconNode:a[0]}];let r={$$slots:{default:[create_default_slot$x]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[t[0],s&2&&get_spread_object(o[1]),s&1&&{iconNode:o[0]}]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$10(a,e,n){let{$$slots:t={},$$scope:r}=e;const o=[["circle",{cx:"11",cy:"11",r:"8"}],["path",{d:"m21 21-4.3-4.3"}]];return a.$$set=s=>{n(1,e=assign(assign({},e),exclude_internal_props(s))),"$$scope"in s&&n(3,r=s.$$scope)},e=exclude_internal_props(e),[o,e,t,r]}class Search extends SvelteComponent{constructor(e){super(),init(this,e,instance$10,create_fragment$Y,safe_not_equal,{})}}function create_default_slot$w(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$X(a){let e,n;const t=[{name:"share-2"},a[1],{iconNode:a[0]}];let r={$$slots:{default:[create_default_slot$w]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[t[0],s&2&&get_spread_object(o[1]),s&1&&{iconNode:o[0]}]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$$(a,e,n){let{$$slots:t={},$$scope:r}=e;const o=[["circle",{cx:"18",cy:"5",r:"3"}],["circle",{cx:"6",cy:"12",r:"3"}],["circle",{cx:"18",cy:"19",r:"3"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49"}]];return a.$$set=s=>{n(1,e=assign(assign({},e),exclude_internal_props(s))),"$$scope"in s&&n(3,r=s.$$scope)},e=exclude_internal_props(e),[o,e,t,r]}class Share_2 extends SvelteComponent{constructor(e){super(),init(this,e,instance$$,create_fragment$X,safe_not_equal,{})}}function create_default_slot$v(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$W(a){let e,n;const t=[{name:"square"},a[1],{iconNode:a[0]}];let r={$$slots:{default:[create_default_slot$v]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[t[0],s&2&&get_spread_object(o[1]),s&1&&{iconNode:o[0]}]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$_(a,e,n){let{$$slots:t={},$$scope:r}=e;const o=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}]];return a.$$set=s=>{n(1,e=assign(assign({},e),exclude_internal_props(s))),"$$scope"in s&&n(3,r=s.$$scope)},e=exclude_internal_props(e),[o,e,t,r]}class Square extends SvelteComponent{constructor(e){super(),init(this,e,instance$_,create_fragment$W,safe_not_equal,{})}}function create_default_slot$u(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$V(a){let e,n;const t=[{name:"trash-2"},a[1],{iconNode:a[0]}];let r={$$slots:{default:[create_default_slot$u]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new Icon({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[t[0],s&2&&get_spread_object(o[1]),s&1&&{iconNode:o[0]}]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$Z(a,e,n){let{$$slots:t={},$$scope:r}=e;const o=[["path",{d:"M3 6h18"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17"}]];return a.$$set=s=>{n(1,e=assign(assign({},e),exclude_internal_props(s))),"$$scope"in s&&n(3,r=s.$$scope)},e=exclude_internal_props(e),[o,e,t,r]}class Trash_2 extends SvelteComponent{constructor(e){super(),init(this,e,instance$Z,create_fragment$V,safe_not_equal,{})}}function styleToString(a){return Object.keys(a).reduce((e,n)=>a[n]===void 0?e:e+`${n}:${a[n]};`,"")}const srOnlyStyles={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function addEventListener(a,e,n,t){const r=Array.isArray(e)?e:[e];return r.forEach(o=>a.addEventListener(o,n,t)),()=>{r.forEach(o=>a.removeEventListener(o,n,t))}}function executeCallbacks(...a){return(...e)=>{for(const n of a)typeof n=="function"&&n(...e)}}const get_default_slot_spread_changes_1=a=>a&4,get_default_slot_changes_1$2=a=>({}),get_default_slot_context_1$2=a=>({...a[2]}),get_default_slot_spread_changes=a=>a&4,get_default_slot_changes$4=a=>({}),get_default_slot_context$4=a=>({...a[2]});function create_else_block$c(a){let e,n,t=(a[0]??"")+"",r,o,s,l,c,f=[a[6]],h={};for(let _=0;_<f.length;_+=1)h=assign(h,f[_]);const u=a[18].default,i=create_slot(u,a,a[17],get_default_slot_context_1$2);let d=[a[5],a[7]],p={};for(let _=0;_<d.length;_+=1)p=assign(p,d[_]);return{c(){e=element("div"),n=element("label"),r=text(t),o=space(),i&&i.c(),this.h()},l(_){e=claim_element(_,"DIV",{});var m=children(e);n=claim_element(m,"LABEL",{});var g=children(n);r=claim_text(g,t),g.forEach(detach),o=claim_space(m),i&&i.l(m),m.forEach(detach),this.h()},h(){set_attributes(n,h),set_attributes(e,p)},m(_,m){insert_hydration(_,e,m),append_hydration(e,n),append_hydration(n,r),append_hydration(e,o),i&&i.m(e,null),s=!0,l||(c=action_destroyer(a[4].call(null,e)),l=!0)},p(_,m){(!s||m&1)&&t!==(t=(_[0]??"")+"")&&set_data_maybe_contenteditable(r,t,h.contenteditable),i&&i.p&&(!s||m&131076)&&update_slot_base(i,u,_,_[17],get_default_slot_spread_changes_1(m)||!s?get_all_dirty_from_scope(_[17]):get_slot_changes(u,_[17],m,get_default_slot_changes_1$2),get_default_slot_context_1$2),set_attributes(e,p=get_spread_update(d,[_[5],m&128&&_[7]]))},i(_){s||(transition_in(i,_),s=!0)},o(_){transition_out(i,_),s=!1},d(_){_&&detach(e),i&&i.d(_),l=!1,c()}}}function create_if_block$w(a){let e;const n=a[18].default,t=create_slot(n,a,a[17],get_default_slot_context$4);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&131076)&&update_slot_base(t,n,r,r[17],get_default_slot_spread_changes(o)||!e?get_all_dirty_from_scope(r[17]):get_slot_changes(n,r[17],o,get_default_slot_changes$4),get_default_slot_context$4)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$U(a){let e,n,t,r;const o=[create_if_block$w,create_else_block$c],s=[];function l(c,f){return c[1]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){let h=e;e=l(c),e===h?s[e].p(c,f):(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function instance$Y(a,e,n){let t;const r=["label","shouldFilter","filter","value","onValueChange","loop","onKeydown","state","ids","asChild"];let o=compute_rest_props(e,r),s,{$$slots:l={},$$scope:c}=e,{label:f=void 0}=e,{shouldFilter:h=!0}=e,{filter:u=void 0}=e,{value:i=void 0}=e,{onValueChange:d=void 0}=e,{loop:p=void 0}=e,{onKeydown:_=void 0}=e,{state:m=void 0}=e,{ids:g=void 0}=e,{asChild:b=!1}=e;const{commandEl:v,handleRootKeydown:T,ids:y,state:w}=createCommand({label:f,shouldFilter:h,filter:u,value:i,onValueChange:k=>{k!==i&&(n(8,i=k),d==null||d(k))},loop:p,state:m,ids:g});component_subscribe(a,w,k=>n(16,s=k));function S(k){k&&k!==s.value&&set_store_value(w,s.value=k,s)}function O(k){return v.set(k),{destroy:executeCallbacks(addEventListener(k,"keydown",A))}}const P={role:"application",id:y.root,"data-cmdk-root":""},E={"data-cmdk-label":"",for:y.input,id:y.label,style:styleToString(srOnlyStyles)};function A(k){_==null||_(k),!k.defaultPrevented&&T(k)}const $={action:O,attrs:P};return a.$$set=k=>{e=assign(assign({},e),exclude_internal_props(k)),n(7,o=compute_rest_props(e,r)),"label"in k&&n(0,f=k.label),"shouldFilter"in k&&n(9,h=k.shouldFilter),"filter"in k&&n(10,u=k.filter),"value"in k&&n(8,i=k.value),"onValueChange"in k&&n(11,d=k.onValueChange),"loop"in k&&n(12,p=k.loop),"onKeydown"in k&&n(13,_=k.onKeydown),"state"in k&&n(14,m=k.state),"ids"in k&&n(15,g=k.ids),"asChild"in k&&n(1,b=k.asChild),"$$scope"in k&&n(17,c=k.$$scope)},a.$$.update=()=>{a.$$.dirty&256&&S(i),a.$$.dirty&65536&&n(2,t={root:$,label:{attrs:E},stateStore:w,state:s})},[f,b,t,w,O,P,E,o,i,h,u,d,p,_,m,g,s,c,l]}let Command$1=class extends SvelteComponent{constructor(e){super(),init(this,e,instance$Y,create_fragment$U,safe_not_equal,{label:0,shouldFilter:9,filter:10,value:8,onValueChange:11,loop:12,onKeydown:13,state:14,ids:15,asChild:1})}};const get_default_slot_changes_1$1=a=>({container:a&32,group:a&16}),get_default_slot_context_1$1=a=>({container:a[5],group:a[4],heading:{attrs:a[8]}}),get_default_slot_changes$3=a=>({container:a&32,group:a&16}),get_default_slot_context$3=a=>({container:a[5],group:a[4],heading:{attrs:a[8]}});function create_else_block$b(a){let e,n,t,r,o,s,l=a[0]&&create_if_block_1$g(a);const c=a[14].default,f=create_slot(c,a,a[13],get_default_slot_context_1$1);let h=[a[2]],u={};for(let p=0;p<h.length;p+=1)u=assign(u,h[p]);let i=[a[3],a[9]],d={};for(let p=0;p<i.length;p+=1)d=assign(d,i[p]);return{c(){e=element("div"),l&&l.c(),n=space(),t=element("div"),f&&f.c(),this.h()},l(p){e=claim_element(p,"DIV",{});var _=children(e);l&&l.l(_),n=claim_space(_),t=claim_element(_,"DIV",{});var m=children(t);f&&f.l(m),m.forEach(detach),_.forEach(detach),this.h()},h(){set_attributes(t,u),set_attributes(e,d)},m(p,_){insert_hydration(p,e,_),l&&l.m(e,null),append_hydration(e,n),append_hydration(e,t),f&&f.m(t,null),r=!0,o||(s=action_destroyer(a[7].call(null,e)),o=!0)},p(p,_){p[0]?l?l.p(p,_):(l=create_if_block_1$g(p),l.c(),l.m(e,n)):l&&(l.d(1),l=null),f&&f.p&&(!r||_&8240)&&update_slot_base(f,c,p,p[13],r?get_slot_changes(c,p[13],_,get_default_slot_changes_1$1):get_all_dirty_from_scope(p[13]),get_default_slot_context_1$1),set_attributes(t,u=get_spread_update(h,[_&4&&p[2]])),set_attributes(e,d=get_spread_update(i,[_&8&&p[3],_&512&&p[9]]))},i(p){r||(transition_in(f,p),r=!0)},o(p){transition_out(f,p),r=!1},d(p){p&&detach(e),l&&l.d(),f&&f.d(p),o=!1,s()}}}function create_if_block$v(a){let e;const n=a[14].default,t=create_slot(n,a,a[13],get_default_slot_context$3);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8240)&&update_slot_base(t,n,r,r[13],e?get_slot_changes(n,r[13],o,get_default_slot_changes$3):get_all_dirty_from_scope(r[13]),get_default_slot_context$3)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_if_block_1$g(a){let e,n,t=[a[8]],r={};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return{c(){e=element("div"),n=text(a[0]),this.h()},l(o){e=claim_element(o,"DIV",{});var s=children(e);n=claim_text(s,a[0]),s.forEach(detach),this.h()},h(){set_attributes(e,r)},m(o,s){insert_hydration(o,e,s),append_hydration(e,n)},p(o,s){s&1&&set_data_maybe_contenteditable(n,o[0],r.contenteditable)},d(o){o&&detach(e)}}}function create_fragment$T(a){let e,n,t,r;const o=[create_if_block$v,create_else_block$b],s=[];function l(c,f){return c[1]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){let h=e;e=l(c),e===h?s[e].p(c,f):(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function instance$X(a,e,n){let t,r,o,s;const l=["heading","value","alwaysRender","asChild"];let c=compute_rest_props(e,l),f,{$$slots:h={},$$scope:u}=e,{heading:i=void 0}=e,{value:d=""}=e,{alwaysRender:p=!1}=e,{asChild:_=!1}=e;const{id:m}=createGroup(p),g=getCtx$5(),b=getState(),v=generateId(),T=derived(b,S=>p||g.filter()===!1||!S.search?!0:S.filtered.groups.has(m));component_subscribe(a,T,S=>n(12,f=S)),onMount(()=>g.group(m));function y(S){if(d){g.value(m,d),S.setAttribute(VALUE_ATTR,d);return}i?n(10,d=i.trim().toLowerCase()):S.textContent&&n(10,d=S.textContent.trim().toLowerCase()),g.value(m,d),S.setAttribute(VALUE_ATTR,d)}const w={"data-cmdk-group-heading":"","aria-hidden":!0,id:v};return a.$$set=S=>{e=assign(assign({},e),exclude_internal_props(S)),n(9,c=compute_rest_props(e,l)),"heading"in S&&n(0,i=S.heading),"value"in S&&n(10,d=S.value),"alwaysRender"in S&&n(11,p=S.alwaysRender),"asChild"in S&&n(1,_=S.asChild),"$$scope"in S&&n(13,u=S.$$scope)},a.$$.update=()=>{a.$$.dirty&5120&&n(3,t={"data-cmdk-group":"",role:"presentation",hidden:f?void 0:!0,"data-value":d}),a.$$.dirty&1&&n(2,r={"data-cmdk-group-items":"",role:"group","aria-labelledby":i?v:void 0}),a.$$.dirty&8&&n(5,o={action:y,attrs:t}),a.$$.dirty&4&&n(4,s={attrs:r})},[i,_,r,t,s,o,T,y,w,c,d,p,f,u,h]}class CommandGroup extends SvelteComponent{constructor(e){super(),init(this,e,instance$X,create_fragment$T,safe_not_equal,{heading:0,value:10,alwaysRender:11,asChild:1})}}function sleep(a){return new Promise(e=>setTimeout(e,a))}const get_default_slot_changes$2=a=>({attrs:a&8}),get_default_slot_context$2=a=>({action:a[6],attrs:a[3]});function create_else_block$a(a){let e,n,t,r=[a[3],a[7]],o={};for(let s=0;s<r.length;s+=1)o=assign(o,r[s]);return{c(){e=element("input"),this.h()},l(s){e=claim_element(s,"INPUT",{}),this.h()},h(){set_attributes(e,o)},m(s,l){insert_hydration(s,e,l),e.autofocus&&e.focus(),a[16](e),set_input_value(e,a[0]),n||(t=[listen(e,"input",a[17]),action_destroyer(a[6].call(null,e)),listen(e,"input",a[12]),listen(e,"focus",a[13]),listen(e,"blur",a[14]),listen(e,"change",a[15])],n=!0)},p(s,l){set_attributes(e,o=get_spread_update(r,[l&8&&s[3],l&128&&s[7]])),l&1&&e.value!==s[0]&&set_input_value(e,s[0])},i:noop,o:noop,d(s){s&&detach(e),a[16](null),n=!1,run_all(t)}}}function create_if_block$u(a){let e;const n=a[11].default,t=create_slot(n,a,a[10],get_default_slot_context$2);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&1032)&&update_slot_base(t,n,r,r[10],e?get_slot_changes(n,r[10],o,get_default_slot_changes$2):get_all_dirty_from_scope(r[10]),get_default_slot_context$2)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$S(a){let e,n,t,r;const o=[create_if_block$u,create_else_block$a],s=[];function l(c,f){return c[2]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){let h=e;e=l(c),e===h?s[e].p(c,f):(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function instance$W(a,e,n){const t=["autofocus","value","asChild","el"];let r=compute_rest_props(e,t),o,s,{$$slots:l={},$$scope:c}=e;const{ids:f,commandEl:h}=getCtx$5(),u=getState(),i=derived(u,$=>$.search);component_subscribe(a,i,$=>n(18,s=$));const d=derived(u,$=>$.value);let{autofocus:p=void 0}=e,{value:_=s}=e,{asChild:m=!1}=e,{el:g=void 0}=e;const b=derived([d,h],([$,k])=>{if(!isBrowser)return;const D=k==null?void 0:k.querySelector(`${ITEM_SELECTOR}[${VALUE_ATTR}="${$}"]`);return D==null?void 0:D.getAttribute("id")});component_subscribe(a,b,$=>n(9,o=$));function v($){u.updateState("search",$)}function T($){return p&&sleep(10).then(()=>$.focus()),{destroy:addEventListener($,"change",D=>{isHTMLInputElement(D.target)&&u.updateState("search",D.target.value)})}}let y;function w($){bubble.call(this,a,$)}function S($){bubble.call(this,a,$)}function O($){bubble.call(this,a,$)}function P($){bubble.call(this,a,$)}function E($){binding_callbacks[$?"unshift":"push"](()=>{g=$,n(1,g)})}function A(){_=this.value,n(0,_)}return a.$$set=$=>{e=assign(assign({},e),exclude_internal_props($)),n(7,r=compute_rest_props(e,t)),"autofocus"in $&&n(8,p=$.autofocus),"value"in $&&n(0,_=$.value),"asChild"in $&&n(2,m=$.asChild),"el"in $&&n(1,g=$.el),"$$scope"in $&&n(10,c=$.$$scope)},a.$$.update=()=>{a.$$.dirty&1&&v(_),a.$$.dirty&512&&n(3,y={type:"text","data-cmdk-input":"",autocomplete:"off",autocorrect:"off",spellcheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":f.list,"aria-labelledby":f.label,"aria-activedescendant":o??void 0,id:f.input})},[_,g,m,y,i,b,T,r,p,o,c,l,w,S,O,P,E,A]}class CommandInput extends SvelteComponent{constructor(e){super(),init(this,e,instance$W,create_fragment$S,safe_not_equal,{autofocus:8,value:0,asChild:2,el:1})}}const get_default_slot_changes_1=a=>({attrs:a&4}),get_default_slot_context_1=a=>({action:a[6],attrs:a[2]}),get_default_slot_changes$1=a=>({attrs:a&4}),get_default_slot_context$1=a=>({action:a[6],attrs:a[2]});function create_if_block$t(a){let e,n,t,r;const o=[create_if_block_1$f,create_else_block$9],s=[];function l(c,f){return c[0]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,f){let h=e;e=l(c),e===h?s[e].p(c,f):(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function create_else_block$9(a){let e,n,t,r;const o=a[15].default,s=create_slot(o,a,a[14],get_default_slot_context_1);let l=[a[2],a[7]],c={};for(let f=0;f<l.length;f+=1)c=assign(c,l[f]);return{c(){e=element("div"),s&&s.c(),this.h()},l(f){e=claim_element(f,"DIV",{});var h=children(e);s&&s.l(h),h.forEach(detach),this.h()},h(){set_attributes(e,c)},m(f,h){insert_hydration(f,e,h),s&&s.m(e,null),n=!0,t||(r=action_destroyer(a[6].call(null,e)),t=!0)},p(f,h){s&&s.p&&(!n||h&16388)&&update_slot_base(s,o,f,f[14],n?get_slot_changes(o,f[14],h,get_default_slot_changes_1):get_all_dirty_from_scope(f[14]),get_default_slot_context_1),set_attributes(e,c=get_spread_update(l,[h&4&&f[2],h&128&&f[7]]))},i(f){n||(transition_in(s,f),n=!0)},o(f){transition_out(s,f),n=!1},d(f){f&&detach(e),s&&s.d(f),t=!1,r()}}}function create_if_block_1$f(a){let e;const n=a[15].default,t=create_slot(n,a,a[14],get_default_slot_context$1);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&16388)&&update_slot_base(t,n,r,r[14],e?get_slot_changes(n,r[14],o,get_default_slot_changes$1):get_all_dirty_from_scope(r[14]),get_default_slot_context$1)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$R(a){let e,n,t=(a[3]||a[1])&&create_if_block$t(a);return{c(){t&&t.c(),e=empty()},l(r){t&&t.l(r),e=empty()},m(r,o){t&&t.m(r,o),insert_hydration(r,e,o),n=!0},p(r,[o]){r[3]||r[1]?t?(t.p(r,o),o&10&&transition_in(t,1)):(t=create_if_block$t(r),t.c(),transition_in(t,1),t.m(e.parentNode,e)):t&&(group_outros(),transition_out(t,1,1,()=>{t=null}),check_outros())},i(r){n||(transition_in(t),n=!0)},o(r){transition_out(t),n=!1},d(r){r&&detach(e),t&&t.d(r)}}}function instance$V(a,e,n){let t;const r=["disabled","value","onSelect","alwaysRender","asChild","id"];let o=compute_rest_props(e,r),s,l,{$$slots:c={},$$scope:f}=e,{disabled:h=!1}=e,{value:u=""}=e,{onSelect:i=void 0}=e,{alwaysRender:d=!1}=e,{asChild:p=!1}=e,{id:_=generateId()}=e;const m=getGroup(),g=getCtx$5(),b=getState(),v=d??(m==null?void 0:m.alwaysRender),T=derived(b,E=>{if(v||g.filter()===!1||!E.search)return!0;const A=E.filtered.items.get(_);return isUndefined(A)?!1:A>0});component_subscribe(a,T,E=>n(3,l=E));let y=!0;onMount(()=>(n(1,y=!1),g.item(_,m==null?void 0:m.id)));const w=derived(b,E=>E.value===u);component_subscribe(a,w,E=>n(13,s=E));function S(E){!u&&E.textContent&&n(8,u=E.textContent.trim().toLowerCase()),g.value(_,u),E.setAttribute(VALUE_ATTR,u);const A=executeCallbacks(addEventListener(E,"pointermove",()=>{h||P()}),addEventListener(E,"click",()=>{h||O()}));return{destroy(){A()}}}function O(){P(),i==null||i(u)}function P(){b.updateState("value",u,!0)}return a.$$set=E=>{e=assign(assign({},e),exclude_internal_props(E)),n(7,o=compute_rest_props(e,r)),"disabled"in E&&n(9,h=E.disabled),"value"in E&&n(8,u=E.value),"onSelect"in E&&n(10,i=E.onSelect),"alwaysRender"in E&&n(11,d=E.alwaysRender),"asChild"in E&&n(0,p=E.asChild),"id"in E&&n(12,_=E.id),"$$scope"in E&&n(14,f=E.$$scope)},a.$$.update=()=>{a.$$.dirty&13056&&n(2,t={"aria-disabled":h?!0:void 0,"aria-selected":s?!0:void 0,"data-disabled":h?!0:void 0,"data-selected":s?!0:void 0,"data-cmdk-item":"","data-value":u,role:"option",id:_})},[p,y,t,l,T,w,S,o,u,h,i,d,_,s,f,c]}class CommandItem extends SvelteComponent{constructor(e){super(),init(this,e,instance$V,create_fragment$R,safe_not_equal,{disabled:9,value:8,onSelect:10,alwaysRender:11,asChild:0,id:12})}}const get_default_slot_changes=a=>({}),get_default_slot_context=a=>({list:a[7],sizer:a[8]});function create_else_block$8(a){let e,n,t=a[2].search==="",r,o,s,l=create_key_block_1$1(a),c=[a[6]],f={};for(let i=0;i<c.length;i+=1)f=assign(f,c[i]);let h=[a[5],a[9]],u={};for(let i=0;i<h.length;i+=1)u=assign(u,h[i]);return{c(){e=element("div"),n=element("div"),l.c(),this.h()},l(i){e=claim_element(i,"DIV",{});var d=children(e);n=claim_element(d,"DIV",{});var p=children(n);l.l(p),p.forEach(detach),d.forEach(detach),this.h()},h(){set_attributes(n,f),set_attributes(e,u)},m(i,d){insert_hydration(i,e,d),append_hydration(e,n),l.m(n,null),a[12](e),r=!0,o||(s=action_destroyer(a[4].call(null,n)),o=!0)},p(i,d){d&4&&safe_not_equal(t,t=i[2].search==="")?(group_outros(),transition_out(l,1,1,noop),check_outros(),l=create_key_block_1$1(i),l.c(),transition_in(l,1),l.m(n,null)):l.p(i,d),set_attributes(e,u=get_spread_update(h,[i[5],d&512&&i[9]]))},i(i){r||(transition_in(l),r=!0)},o(i){transition_out(l),r=!1},d(i){i&&detach(e),l.d(i),a[12](null),o=!1,s()}}}function create_if_block$s(a){let e=a[2].search==="",n,t,r=create_key_block$3(a);return{c(){r.c(),n=empty()},l(o){r.l(o),n=empty()},m(o,s){r.m(o,s),insert_hydration(o,n,s),t=!0},p(o,s){s&4&&safe_not_equal(e,e=o[2].search==="")?(group_outros(),transition_out(r,1,1,noop),check_outros(),r=create_key_block$3(o),r.c(),transition_in(r,1),r.m(n.parentNode,n)):r.p(o,s)},i(o){t||(transition_in(r),t=!0)},o(o){transition_out(r),t=!1},d(o){o&&detach(n),r.d(o)}}}function create_key_block_1$1(a){let e;const n=a[11].default,t=create_slot(n,a,a[10],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&1024)&&update_slot_base(t,n,r,r[10],e?get_slot_changes(n,r[10],o,null):get_all_dirty_from_scope(r[10]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_key_block$3(a){let e;const n=a[11].default,t=create_slot(n,a,a[10],get_default_slot_context);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&1024)&&update_slot_base(t,n,r,r[10],e?get_slot_changes(n,r[10],o,get_default_slot_changes):get_all_dirty_from_scope(r[10]),get_default_slot_context)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$Q(a){let e,n,t,r;const o=[create_if_block$s,create_else_block$8],s=[];function l(c,f){return c[1]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){let h=e;e=l(c),e===h?s[e].p(c,f):(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function instance$U(a,e,n){const t=["el","asChild"];let r=compute_rest_props(e,t),o,{$$slots:s={},$$scope:l}=e;const{ids:c}=getCtx$5(),f=getState();component_subscribe(a,f,b=>n(2,o=b));let{el:h=void 0}=e,{asChild:u=!1}=e;function i(b){let v;const T=b.closest("[data-cmdk-list]");if(!isHTMLElement(T))return;const y=new ResizeObserver(()=>{v=requestAnimationFrame(()=>{const w=b.offsetHeight;T.style.setProperty("--cmdk-list-height",w.toFixed(1)+"px")})});return y.observe(b),{destroy(){cancelAnimationFrame(v),y.unobserve(b)}}}const d={"data-cmdk-list":"",role:"listbox","aria-label":"Suggestions",id:c.list,"aria-labelledby":c.input},p={"data-cmdk-list-sizer":""},_={attrs:d},m={attrs:p,action:i};function g(b){binding_callbacks[b?"unshift":"push"](()=>{h=b,n(0,h)})}return a.$$set=b=>{e=assign(assign({},e),exclude_internal_props(b)),n(9,r=compute_rest_props(e,t)),"el"in b&&n(0,h=b.el),"asChild"in b&&n(1,u=b.asChild),"$$scope"in b&&n(10,l=b.$$scope)},[h,u,o,f,i,d,p,_,m,r,l,s,g]}class CommandList extends SvelteComponent{constructor(e){super(),init(this,e,instance$U,create_fragment$Q,safe_not_equal,{el:0,asChild:1})}}function create_default_slot$t(a){let e;const n=a[3].default,t=create_slot(n,a,a[5],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&32)&&update_slot_base(t,n,r,r[5],e?get_slot_changes(n,r[5],o,null):get_all_dirty_from_scope(r[5]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$P(a){let e,n,t;const r=[{class:cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground relative",a[1])},a[2]];function o(l){a[4](l)}let s={$$slots:{default:[create_default_slot$t]},$$scope:{ctx:a}};for(let l=0;l<r.length;l+=1)s=assign(s,r[l]);return a[0]!==void 0&&(s.value=a[0]),e=new Command$1({props:s}),binding_callbacks.push(()=>bind(e,"value",o)),{c(){create_component(e.$$.fragment)},l(l){claim_component(e.$$.fragment,l)},m(l,c){mount_component(e,l,c),t=!0},p(l,[c]){const f=c&6?get_spread_update(r,[c&2&&{class:cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground relative",l[1])},c&4&&get_spread_object(l[2])]):{};c&32&&(f.$$scope={dirty:c,ctx:l}),!n&&c&1&&(n=!0,f.value=l[0],add_flush_callback(()=>n=!1)),e.$set(f)},i(l){t||(transition_in(e.$$.fragment,l),t=!0)},o(l){transition_out(e.$$.fragment,l),t=!1},d(l){destroy_component(e,l)}}}function instance$T(a,e,n){const t=["value","class"];let r=compute_rest_props(e,t),{$$slots:o={},$$scope:s}=e,{value:l=void 0}=e,{class:c=void 0}=e;function f(h){l=h,n(0,l)}return a.$$set=h=>{e=assign(assign({},e),exclude_internal_props(h)),n(2,r=compute_rest_props(e,t)),"value"in h&&n(0,l=h.value),"class"in h&&n(1,c=h.class),"$$scope"in h&&n(5,s=h.$$scope)},[l,c,r,o,f,s]}class Command extends SvelteComponent{constructor(e){super(),init(this,e,instance$T,create_fragment$P,safe_not_equal,{value:0,class:1})}}function create_default_slot$s(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$O(a){let e,n;const t=[{class:cn("overflow-hidden p-1 text-foreground [&_[data-cmdk-group-heading]]:px-2 [&_[data-cmdk-group-heading]]:py-1.5 [&_[data-cmdk-group-heading]]:text-xs [&_[data-cmdk-group-heading]]:font-medium [&_[data-cmdk-group-heading]]:text-muted-foreground",a[0])},a[1]];let r={$$slots:{default:[create_default_slot$s]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new CommandGroup({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[s&1&&{class:cn("overflow-hidden p-1 text-foreground [&_[data-cmdk-group-heading]]:px-2 [&_[data-cmdk-group-heading]]:py-1.5 [&_[data-cmdk-group-heading]]:text-xs [&_[data-cmdk-group-heading]]:font-medium [&_[data-cmdk-group-heading]]:text-muted-foreground",o[0])},s&2&&get_spread_object(o[1])]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$S(a,e,n){const t=["class"];let r=compute_rest_props(e,t),{$$slots:o={},$$scope:s}=e,{class:l=void 0}=e;return a.$$set=c=>{e=assign(assign({},e),exclude_internal_props(c)),n(1,r=compute_rest_props(e,t)),"class"in c&&n(0,l=c.class),"$$scope"in c&&n(3,s=c.$$scope)},[l,r,o,s]}class Command_group extends SvelteComponent{constructor(e){super(),init(this,e,instance$S,create_fragment$O,safe_not_equal,{class:0})}}function create_default_slot$r(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$N(a){let e,n;const t=[{class:cn("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a[0])},a[1]];let r={$$slots:{default:[create_default_slot$r]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new CommandItem({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[s&1&&{class:cn("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",o[0])},s&2&&get_spread_object(o[1])]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$R(a,e,n){const t=["class"];let r=compute_rest_props(e,t),{$$slots:o={},$$scope:s}=e,{class:l=void 0}=e;return a.$$set=c=>{e=assign(assign({},e),exclude_internal_props(c)),n(1,r=compute_rest_props(e,t)),"class"in c&&n(0,l=c.class),"$$scope"in c&&n(3,s=c.$$scope)},[l,r,o,s]}class Command_item extends SvelteComponent{constructor(e){super(),init(this,e,instance$R,create_fragment$N,safe_not_equal,{class:0})}}function create_fragment$M(a){let e,n,t,r,o,s;n=new Search({props:{class:"mr-2 h-4 w-4 shrink-0 opacity-50"}});const l=[{class:cn("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a[1])},a[2]];function c(h){a[3](h)}let f={};for(let h=0;h<l.length;h+=1)f=assign(f,l[h]);return a[0]!==void 0&&(f.value=a[0]),r=new CommandInput({props:f}),binding_callbacks.push(()=>bind(r,"value",c)),r.$on("input",a[4]),r.$on("focus",a[5]),r.$on("blur",a[6]),{c(){e=element("div"),create_component(n.$$.fragment),t=space(),create_component(r.$$.fragment),this.h()},l(h){e=claim_element(h,"DIV",{class:!0,"data-cmdk-input-wrapper":!0});var u=children(e);claim_component(n.$$.fragment,u),t=claim_space(u),claim_component(r.$$.fragment,u),u.forEach(detach),this.h()},h(){attr(e,"class","flex items-center border-b px-2"),attr(e,"data-cmdk-input-wrapper","")},m(h,u){insert_hydration(h,e,u),mount_component(n,e,null),append_hydration(e,t),mount_component(r,e,null),s=!0},p(h,[u]){const i=u&6?get_spread_update(l,[u&2&&{class:cn("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",h[1])},u&4&&get_spread_object(h[2])]):{};!o&&u&1&&(o=!0,i.value=h[0],add_flush_callback(()=>o=!1)),r.$set(i)},i(h){s||(transition_in(n.$$.fragment,h),transition_in(r.$$.fragment,h),s=!0)},o(h){transition_out(n.$$.fragment,h),transition_out(r.$$.fragment,h),s=!1},d(h){h&&detach(e),destroy_component(n),destroy_component(r)}}}function instance$Q(a,e,n){const t=["class","value"];let r=compute_rest_props(e,t),{class:o=void 0}=e,{value:s=""}=e;function l(u){s=u,n(0,s)}function c(u){bubble.call(this,a,u)}function f(u){bubble.call(this,a,u)}function h(u){bubble.call(this,a,u)}return a.$$set=u=>{e=assign(assign({},e),exclude_internal_props(u)),n(2,r=compute_rest_props(e,t)),"class"in u&&n(1,o=u.class),"value"in u&&n(0,s=u.value)},[s,o,r,l,c,f,h]}class Command_input extends SvelteComponent{constructor(e){super(),init(this,e,instance$Q,create_fragment$M,safe_not_equal,{class:1,value:0})}}function create_default_slot$q(a){let e;const n=a[2].default,t=create_slot(n,a,a[3],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&8)&&update_slot_base(t,n,r,r[3],e?get_slot_changes(n,r[3],o,null):get_all_dirty_from_scope(r[3]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$L(a){let e,n;const t=[{class:cn("max-h-[300px] overflow-y-auto overflow-x-hidden",a[0])},a[1]];let r={$$slots:{default:[create_default_slot$q]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new CommandList({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&3?get_spread_update(t,[s&1&&{class:cn("max-h-[300px] overflow-y-auto overflow-x-hidden",o[0])},s&2&&get_spread_object(o[1])]):{};s&8&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$P(a,e,n){const t=["class"];let r=compute_rest_props(e,t),{$$slots:o={},$$scope:s}=e,{class:l=void 0}=e;return a.$$set=c=>{e=assign(assign({},e),exclude_internal_props(c)),n(1,r=compute_rest_props(e,t)),"class"in c&&n(0,l=c.class),"$$scope"in c&&n(3,s=c.$$scope)},[l,r,o,s]}class Command_list extends SvelteComponent{constructor(e){super(),init(this,e,instance$P,create_fragment$L,safe_not_equal,{class:0})}}function create_default_slot$p(a){let e;const n=a[4].default,t=create_slot(n,a,a[5],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&32)&&update_slot_base(t,n,r,r[5],e?get_slot_changes(n,r[5],o,null):get_all_dirty_from_scope(r[5]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$K(a){let e,n;const t=[{transition:a[1]},{transitionConfig:a[2]},{class:cn("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none",a[0])},a[3]];let r={$$slots:{default:[create_default_slot$p]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new PopoverContent({props:r}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&15?get_spread_update(t,[s&2&&{transition:o[1]},s&4&&{transitionConfig:o[2]},s&1&&{class:cn("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none",o[0])},s&8&&get_spread_object(o[3])]):{};s&32&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$O(a,e,n){const t=["class","transition","transitionConfig"];let r=compute_rest_props(e,t),{$$slots:o={},$$scope:s}=e,{class:l=void 0}=e,{transition:c=flyAndScale}=e,{transitionConfig:f=void 0}=e;return a.$$set=h=>{e=assign(assign({},e),exclude_internal_props(h)),n(3,r=compute_rest_props(e,t)),"class"in h&&n(0,l=h.class),"transition"in h&&n(1,c=h.transition),"transitionConfig"in h&&n(2,f=h.transitionConfig),"$$scope"in h&&n(5,s=h.$$scope)},[l,c,f,r,o,s]}class Popover_content extends SvelteComponent{constructor(e){super(),init(this,e,instance$O,create_fragment$K,safe_not_equal,{class:0,transition:1,transitionConfig:2})}}const Root$1=Popover,Trigger$1=PopoverTrigger;function get_each_context$b(a,e,n){const t=a.slice();return t[11]=e[n],t}function create_default_slot_6$1(a){let e,n,t,r;return t=new Chevrons_up_down({props:{class:"ml-2 h-4 w-4 shrink-0 opacity-50"}}),{c(){e=text(a[4]),n=space(),create_component(t.$$.fragment)},l(o){e=claim_text(o,a[4]),n=claim_space(o),claim_component(t.$$.fragment,o)},m(o,s){insert_hydration(o,e,s),insert_hydration(o,n,s),mount_component(t,o,s),r=!0},p(o,s){(!r||s&16)&&set_data(e,o[4])},i(o){r||(transition_in(t.$$.fragment,o),r=!0)},o(o){transition_out(t.$$.fragment,o),r=!1},d(o){o&&(detach(e),detach(n)),destroy_component(t,o)}}}function create_default_slot_5$5(a){let e,n;return e=new Button({props:{builders:[a[14]],variant:"outline",role:"combobox","aria-expanded":a[3],class:cn("justify-between",a[2]),$$slots:{default:[create_default_slot_6$1]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r&16384&&(o.builders=[t[14]]),r&8&&(o["aria-expanded"]=t[3]),r&4&&(o.class=cn("justify-between",t[2])),r&32784&&(o.$$scope={dirty:r,ctx:t}),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_default_slot_4$6(a){let e,n,t=a[11].label+"",r,o,s;return e=new Check({props:{class:cn("mr-2 h-4 w-4",a[0]!==a[11].value&&"text-transparent")}}),{c(){create_component(e.$$.fragment),n=space(),r=text(t),o=space()},l(l){claim_component(e.$$.fragment,l),n=claim_space(l),r=claim_text(l,t),o=claim_space(l)},m(l,c){mount_component(e,l,c),insert_hydration(l,n,c),insert_hydration(l,r,c),insert_hydration(l,o,c),s=!0},p(l,c){const f={};c&3&&(f.class=cn("mr-2 h-4 w-4",l[0]!==l[11].value&&"text-transparent")),e.$set(f),(!s||c&2)&&t!==(t=l[11].label+"")&&set_data(r,t)},i(l){s||(transition_in(e.$$.fragment,l),s=!0)},o(l){transition_out(e.$$.fragment,l),s=!1},d(l){l&&(detach(n),detach(r),detach(o)),destroy_component(e,l)}}}function create_each_block$b(a){let e,n;function t(...r){return a[8](a[10],...r)}return e=new Command_item({props:{value:a[11].value,onSelect:t,$$slots:{default:[create_default_slot_4$6]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,o){mount_component(e,r,o),n=!0},p(r,o){a=r;const s={};o&2&&(s.value=a[11].value),o&1025&&(s.onSelect=t),o&32771&&(s.$$scope={dirty:o,ctx:a}),e.$set(s)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_default_slot_3$8(a){let e,n,t=ensure_array_like(a[1]),r=[];for(let s=0;s<t.length;s+=1)r[s]=create_each_block$b(get_each_context$b(a,t,s));const o=s=>transition_out(r[s],1,1,()=>{r[s]=null});return{c(){for(let s=0;s<r.length;s+=1)r[s].c();e=empty()},l(s){for(let l=0;l<r.length;l+=1)r[l].l(s);e=empty()},m(s,l){for(let c=0;c<r.length;c+=1)r[c]&&r[c].m(s,l);insert_hydration(s,e,l),n=!0},p(s,l){if(l&1059){t=ensure_array_like(s[1]);let c;for(c=0;c<t.length;c+=1){const f=get_each_context$b(s,t,c);r[c]?(r[c].p(f,l),transition_in(r[c],1)):(r[c]=create_each_block$b(f),r[c].c(),transition_in(r[c],1),r[c].m(e.parentNode,e))}for(group_outros(),c=t.length;c<r.length;c+=1)o(c);check_outros()}},i(s){if(!n){for(let l=0;l<t.length;l+=1)transition_in(r[l]);n=!0}},o(s){r=r.filter(Boolean);for(let l=0;l<r.length;l+=1)transition_out(r[l]);n=!1},d(s){s&&detach(e),destroy_each(r,s)}}}function create_default_slot_2$8(a){let e,n;return e=new Command_group({props:{$$slots:{default:[create_default_slot_3$8]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r&33795&&(o.$$scope={dirty:r,ctx:t}),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_default_slot_1$b(a){let e,n;return e=new Command({props:{$$slots:{default:[create_default_slot_2$8]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r&33795&&(o.$$scope={dirty:r,ctx:t}),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_default_slot$o(a){let e,n,t,r;return e=new Trigger$1({props:{asChild:!0,$$slots:{default:[create_default_slot_5$5,({builder:o})=>({14:o}),({builder:o})=>o?16384:0]},$$scope:{ctx:a}}}),t=new Popover_content({props:{class:cn("p-0",a[2]),$$slots:{default:[create_default_slot_1$b]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment),n=space(),create_component(t.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(t.$$.fragment,o)},m(o,s){mount_component(e,o,s),insert_hydration(o,n,s),mount_component(t,o,s),r=!0},p(o,s){const l={};s&49180&&(l.$$scope={dirty:s,ctx:o}),e.$set(l);const c={};s&4&&(c.class=cn("p-0",o[2])),s&33795&&(c.$$scope={dirty:s,ctx:o}),t.$set(c)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(t.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(t.$$.fragment,o),r=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(t,o)}}}function create_fragment$J(a){let e,n,t;function r(s){a[9](s)}let o={$$slots:{default:[create_default_slot$o,({ids:s})=>({10:s}),({ids:s})=>s?1024:0]},$$scope:{ctx:a}};return a[3]!==void 0&&(o.open=a[3]),e=new Root$1({props:o}),binding_callbacks.push(()=>bind(e,"open",r)),{c(){create_component(e.$$.fragment)},l(s){claim_component(e.$$.fragment,s)},m(s,l){mount_component(e,s,l),t=!0},p(s,[l]){const c={};l&33823&&(c.$$scope={dirty:l,ctx:s}),!n&&l&8&&(n=!0,c.open=s[3],add_flush_callback(()=>n=!1)),e.$set(c)},i(s){t||(transition_in(e.$$.fragment,s),t=!0)},o(s){transition_out(e.$$.fragment,s),t=!1},d(s){destroy_component(e,s)}}}function instance$N(a,e,n){let t,{listItems:r=[]}=e,{placeholder:o="Select an item"}=e,s=!1,{value:l=""}=e,{saveValue:c=()=>{}}=e,{width:f="w-[200px]"}=e;function h(d){n(3,s=!1),tick().then(()=>{var p;(p=document.getElementById(d))==null||p.focus()},()=>{})}const u=(d,p)=>{n(0,l=p),h(d.trigger)};function i(d){s=d,n(3,s)}return a.$$set=d=>{"listItems"in d&&n(1,r=d.listItems),"placeholder"in d&&n(6,o=d.placeholder),"value"in d&&n(0,l=d.value),"saveValue"in d&&n(7,c=d.saveValue),"width"in d&&n(2,f=d.width)},a.$$.update=()=>{var d;a.$$.dirty&67&&n(4,t=((d=r.find(p=>p.value===l))==null?void 0:d.label)??o),a.$$.dirty&129&&l&&c(l)},[l,r,f,s,t,h,o,c,u,i]}class Combobox extends SvelteComponent{constructor(e){super(),init(this,e,instance$N,create_fragment$J,safe_not_equal,{listItems:1,placeholder:6,value:0,saveValue:7,width:2})}}function create_fragment$I(a){let e,n,t,r,o,s,l,c;const f=a[5].default,h=create_slot(f,a,a[4],null);let u=[{class:r=cn("w-full p-2 placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",a[1])},a[3],a[2]?{autofocus:!0}:{}],i={};for(let d=0;d<u.length;d+=1)i=assign(i,u[d]);return{c(){e=element("div"),h&&h.c(),n=space(),t=element("input"),this.h()},l(d){e=claim_element(d,"DIV",{class:!0});var p=children(e);h&&h.l(p),n=claim_space(p),t=claim_element(p,"INPUT",{class:!0}),p.forEach(detach),this.h()},h(){set_attributes(t,i),attr(e,"class",o=cn("flex h-10 items-center rounded-md border border-input bg-white pl-3 text-sm ring-offset-background focus-within:ring-1 focus-within:ring-ring focus-within:ring-offset-2",a[1]))},m(d,p){insert_hydration(d,e,p),h&&h.m(e,null),append_hydration(e,n),append_hydration(e,t),t.autofocus&&t.focus(),set_input_value(t,a[0]),s=!0,l||(c=[listen(t,"input",a[18]),listen(t,"blur",a[6]),listen(t,"change",a[7]),listen(t,"click",a[8]),listen(t,"focus",a[9]),listen(t,"keydown",a[10]),listen(t,"keypress",a[11]),listen(t,"keyup",a[12]),listen(t,"mouseover",a[13]),listen(t,"mouseenter",a[14]),listen(t,"mouseleave",a[15]),listen(t,"paste",a[16]),listen(t,"input",a[17])],l=!0)},p(d,[p]){h&&h.p&&(!s||p&16)&&update_slot_base(h,f,d,d[4],s?get_slot_changes(f,d[4],p,null):get_all_dirty_from_scope(d[4]),null),set_attributes(t,i=get_spread_update(u,[(!s||p&2&&r!==(r=cn("w-full p-2 placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",d[1])))&&{class:r},p&8&&d[3],p&4&&(d[2]?{autofocus:!0}:{})])),p&1&&t.value!==d[0]&&set_input_value(t,d[0]),(!s||p&2&&o!==(o=cn("flex h-10 items-center rounded-md border border-input bg-white pl-3 text-sm ring-offset-background focus-within:ring-1 focus-within:ring-ring focus-within:ring-offset-2",d[1])))&&attr(e,"class",o)},i(d){s||(transition_in(h,d),s=!0)},o(d){transition_out(h,d),s=!1},d(d){d&&detach(e),h&&h.d(d),l=!1,run_all(c)}}}function instance$M(a,e,n){const t=["class","value","autofocus"];let r=compute_rest_props(e,t),{$$slots:o={},$$scope:s}=e,{class:l=void 0}=e,{value:c=void 0}=e,{autofocus:f=!1}=e;function h(S){bubble.call(this,a,S)}function u(S){bubble.call(this,a,S)}function i(S){bubble.call(this,a,S)}function d(S){bubble.call(this,a,S)}function p(S){bubble.call(this,a,S)}function _(S){bubble.call(this,a,S)}function m(S){bubble.call(this,a,S)}function g(S){bubble.call(this,a,S)}function b(S){bubble.call(this,a,S)}function v(S){bubble.call(this,a,S)}function T(S){bubble.call(this,a,S)}function y(S){bubble.call(this,a,S)}function w(){c=this.value,n(0,c)}return a.$$set=S=>{e=assign(assign({},e),exclude_internal_props(S)),n(3,r=compute_rest_props(e,t)),"class"in S&&n(1,l=S.class),"value"in S&&n(0,c=S.value),"autofocus"in S&&n(2,f=S.autofocus),"$$scope"in S&&n(4,s=S.$$scope)},[c,l,f,r,s,o,h,u,i,d,p,_,m,g,b,v,T,y,w]}class Input extends SvelteComponent{constructor(e){super(),init(this,e,instance$M,create_fragment$I,safe_not_equal,{class:1,value:0,autofocus:2})}}function create_if_block$r(a){let e;return{c(){e=text(a[4])},l(n){e=claim_text(n,a[4])},m(n,t){insert_hydration(n,e,t)},p(n,t){t&16&&set_data(e,n[4])},d(n){n&&detach(e)}}}function create_default_slot$n(a){let e,n,t,r,o,s,l,c,f;n=new SliderRange({props:{class:"absolute h-full bg-primary"}});let h=a[3]&&a[2]>0&&a[2]<a[5].max*100&&create_if_block$r(a);return{c(){e=element("span"),create_component(n.$$.fragment),t=space(),r=element("button"),h&&h.c(),this.h()},l(u){e=claim_element(u,"SPAN",{class:!0});var i=children(e);claim_component(n.$$.fragment,i),i.forEach(detach),t=claim_space(u),r=claim_element(u,"BUTTON",{role:!0,"aria-valuemin":!0,"aria-valuemax":!0,"aria-valuenow":!0,"data-melt-part":!0,tabindex:!0,"data-melt-slider-thumb":!0,class:!0,"data-bits-slider-thumb":!0,style:!0});var d=children(r);h&&h.l(d),d.forEach(detach),this.h()},h(){attr(e,"class","relative h-2 w-full grow overflow-hidden rounded-full bg-white"),attr(r,"role","slider"),attr(r,"aria-valuemin","0"),attr(r,"aria-valuemax","100"),attr(r,"aria-valuenow",a[2]),attr(r,"data-melt-part","thumb"),attr(r,"tabindex","0"),attr(r,"data-melt-slider-thumb",""),attr(r,"class",o=cn("block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{"h-10 w-10":a[3]})),attr(r,"data-bits-slider-thumb",""),attr(r,"style",s=`position: absolute; left: ${a[2]}%; translate: -50%;`)},m(u,i){insert_hydration(u,e,i),mount_component(n,e,null),insert_hydration(u,t,i),insert_hydration(u,r,i),h&&h.m(r,null),l=!0,c||(f=[listen(r,"mouseenter",a[7]),listen(r,"mouseleave",a[8])],c=!0)},p(u,i){u[3]&&u[2]>0&&u[2]<u[5].max*100?h?h.p(u,i):(h=create_if_block$r(u),h.c(),h.m(r,null)):h&&(h.d(1),h=null),(!l||i&4)&&attr(r,"aria-valuenow",u[2]),(!l||i&8&&o!==(o=cn("block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{"h-10 w-10":u[3]})))&&attr(r,"class",o),(!l||i&4&&s!==(s=`position: absolute; left: ${u[2]}%; translate: -50%;`))&&attr(r,"style",s)},i(u){l||(transition_in(n.$$.fragment,u),l=!0)},o(u){transition_out(n.$$.fragment,u),l=!1},d(u){u&&(detach(e),detach(t),detach(r)),destroy_component(n),h&&h.d(),c=!1,run_all(f)}}}function create_fragment$H(a){let e,n,t="0",r,o,s,l,c,f=a[5].max+"",h,u;const i=[{class:cn(" relative flex w-full touch-none select-none items-center",a[1])},a[5]];function d(_){a[9](_)}let p={$$slots:{default:[create_default_slot$n]},$$scope:{ctx:a}};for(let _=0;_<i.length;_+=1)p=assign(p,i[_]);return a[0]!==void 0&&(p.value=a[0]),o=new Slider({props:p}),binding_callbacks.push(()=>bind(o,"value",d)),{c(){e=element("div"),n=element("span"),n.textContent=t,r=space(),create_component(o.$$.fragment),l=space(),c=element("span"),h=text(f),this.h()},l(_){e=claim_element(_,"DIV",{class:!0});var m=children(e);n=claim_element(m,"SPAN",{"data-svelte-h":!0}),get_svelte_dataset(n)!=="svelte-spsr2y"&&(n.textContent=t),r=claim_space(m),claim_component(o.$$.fragment,m),l=claim_space(m),c=claim_element(m,"SPAN",{});var g=children(c);h=claim_text(g,f),g.forEach(detach),m.forEach(detach),this.h()},h(){attr(e,"class","flex gap-4")},m(_,m){insert_hydration(_,e,m),append_hydration(e,n),append_hydration(e,r),mount_component(o,e,null),append_hydration(e,l),append_hydration(e,c),append_hydration(c,h),u=!0},p(_,[m]){const g=m&34?get_spread_update(i,[m&2&&{class:cn(" relative flex w-full touch-none select-none items-center",_[1])},m&32&&get_spread_object(_[5])]):{};m&1084&&(g.$$scope={dirty:m,ctx:_}),!s&&m&1&&(s=!0,g.value=_[0],add_flush_callback(()=>s=!1)),o.$set(g),(!u||m&32)&&f!==(f=_[5].max+"")&&set_data(h,f)},i(_){u||(transition_in(o.$$.fragment,_),u=!0)},o(_){transition_out(o.$$.fragment,_),u=!1},d(_){_&&detach(e),destroy_component(o)}}}function instance$L(a,e,n){let t,r;const o=["class","value","onChange"];let s=compute_rest_props(e,o),{class:l=void 0}=e,{value:c=[0]}=e,f=!1,{onChange:h}=e;const u=()=>n(3,f=!0),i=()=>n(3,f=!1);function d(p){c=p,n(0,c)}return a.$$set=p=>{e=assign(assign({},e),exclude_internal_props(p)),n(5,s=compute_rest_props(e,o)),"class"in p&&n(1,l=p.class),"value"in p&&n(0,c=p.value),"onChange"in p&&n(6,h=p.onChange)},a.$$.update=()=>{n(2,t=Math.round(((c==null?void 0:c[0])||0)/s.max*100)),a.$$.dirty&4&&n(4,r=`${t/100}`),a.$$.dirty&65&&h(c)},[c,l,t,f,r,s,h,u,i,d]}class SliderWithValue extends SvelteComponent{constructor(e){super(),init(this,e,instance$L,create_fragment$H,safe_not_equal,{class:1,value:0,onChange:6})}}function create_default_slot$m(a){let e,n,t,r,o;return n=new SliderRange({props:{class:"absolute h-full bg-primary"}}),r=new SliderThumb({props:{class:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"}}),{c(){e=element("span"),create_component(n.$$.fragment),t=space(),create_component(r.$$.fragment),this.h()},l(s){e=claim_element(s,"SPAN",{class:!0});var l=children(e);claim_component(n.$$.fragment,l),l.forEach(detach),t=claim_space(s),claim_component(r.$$.fragment,s),this.h()},h(){attr(e,"class","relative h-2 w-full grow overflow-hidden rounded-full bg-secondary")},m(s,l){insert_hydration(s,e,l),mount_component(n,e,null),insert_hydration(s,t,l),mount_component(r,s,l),o=!0},p:noop,i(s){o||(transition_in(n.$$.fragment,s),transition_in(r.$$.fragment,s),o=!0)},o(s){transition_out(n.$$.fragment,s),transition_out(r.$$.fragment,s),o=!1},d(s){s&&(detach(e),detach(t)),destroy_component(n),destroy_component(r,s)}}}function create_fragment$G(a){let e,n,t;const r=[{class:cn("relative flex w-full touch-none select-none items-center",a[1])},a[2]];function o(l){a[3](l)}let s={$$slots:{default:[create_default_slot$m]},$$scope:{ctx:a}};for(let l=0;l<r.length;l+=1)s=assign(s,r[l]);return a[0]!==void 0&&(s.value=a[0]),e=new Slider({props:s}),binding_callbacks.push(()=>bind(e,"value",o)),{c(){create_component(e.$$.fragment)},l(l){claim_component(e.$$.fragment,l)},m(l,c){mount_component(e,l,c),t=!0},p(l,[c]){const f=c&6?get_spread_update(r,[c&2&&{class:cn("relative flex w-full touch-none select-none items-center",l[1])},c&4&&get_spread_object(l[2])]):{};c&16&&(f.$$scope={dirty:c,ctx:l}),!n&&c&1&&(n=!0,f.value=l[0],add_flush_callback(()=>n=!1)),e.$set(f)},i(l){t||(transition_in(e.$$.fragment,l),t=!0)},o(l){transition_out(e.$$.fragment,l),t=!1},d(l){destroy_component(e,l)}}}function instance$K(a,e,n){const t=["class","value"];let r=compute_rest_props(e,t),{class:o=void 0}=e,{value:s=[0]}=e;function l(c){s=c,n(0,s)}return a.$$set=c=>{e=assign(assign({},e),exclude_internal_props(c)),n(2,r=compute_rest_props(e,t)),"class"in c&&n(1,o=c.class),"value"in c&&n(0,s=c.value)},[s,o,r,l]}class SliderRoot extends SvelteComponent{constructor(e){super(),init(this,e,instance$K,create_fragment$G,safe_not_equal,{class:1,value:0})}}function create_default_slot$l(a){let e,n;return e=new SwitchThumb({props:{class:cn("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p:noop,i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_fragment$F(a){let e,n,t;const r=[{class:cn("peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",a[1])},a[2]];function o(l){a[4](l)}let s={$$slots:{default:[create_default_slot$l]},$$scope:{ctx:a}};for(let l=0;l<r.length;l+=1)s=assign(s,r[l]);return a[0]!==void 0&&(s.checked=a[0]),e=new Switch({props:s}),binding_callbacks.push(()=>bind(e,"checked",o)),{c(){create_component(e.$$.fragment)},l(l){claim_component(e.$$.fragment,l)},m(l,c){mount_component(e,l,c),t=!0},p(l,[c]){const f=c&6?get_spread_update(r,[c&2&&{class:cn("peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",l[1])},c&4&&get_spread_object(l[2])]):{};c&32&&(f.$$scope={dirty:c,ctx:l}),!n&&c&1&&(n=!0,f.checked=l[0],add_flush_callback(()=>n=!1)),e.$set(f)},i(l){t||(transition_in(e.$$.fragment,l),t=!0)},o(l){transition_out(e.$$.fragment,l),t=!1},d(l){destroy_component(e,l)}}}function instance$J(a,e,n){const t=["class","checked","onChange"];let r=compute_rest_props(e,t),{class:o=void 0}=e,{checked:s=void 0}=e,{onChange:l}=e;function c(f){s=f,n(0,s)}return a.$$set=f=>{e=assign(assign({},e),exclude_internal_props(f)),n(2,r=compute_rest_props(e,t)),"class"in f&&n(1,o=f.class),"checked"in f&&n(0,s=f.checked),"onChange"in f&&n(3,l=f.onChange)},a.$$.update=()=>{a.$$.dirty&9&&l(s)},[s,o,r,l,c]}class SwitchRoot extends SvelteComponent{constructor(e){super(),init(this,e,instance$J,create_fragment$F,safe_not_equal,{class:1,checked:0,onChange:3})}}function create_default_slot$k(a){let e;const n=a[3].default,t=create_slot(n,a,a[11],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&2048)&&update_slot_base(t,n,r,r[11],e?get_slot_changes(n,r[11],o,null):get_all_dirty_from_scope(r[11]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$E(a){let e,n;const t=[{class:cn("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:opacity-50",a[1]&&"pl-8",a[0])},a[2]];let r={$$slots:{default:[create_default_slot$k]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new ContextMenuItem({props:r}),e.$on("click",a[4]),e.$on("keydown",a[5]),e.$on("focusin",a[6]),e.$on("focusout",a[7]),e.$on("pointerdown",a[8]),e.$on("pointerleave",a[9]),e.$on("pointermove",a[10]),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&7?get_spread_update(t,[s&3&&{class:cn("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:opacity-50",o[1]&&"pl-8",o[0])},s&4&&get_spread_object(o[2])]):{};s&2048&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$I(a,e,n){const t=["class","inset"];let r=compute_rest_props(e,t),{$$slots:o={},$$scope:s}=e,{class:l=void 0}=e,{inset:c=void 0}=e;function f(m){bubble.call(this,a,m)}function h(m){bubble.call(this,a,m)}function u(m){bubble.call(this,a,m)}function i(m){bubble.call(this,a,m)}function d(m){bubble.call(this,a,m)}function p(m){bubble.call(this,a,m)}function _(m){bubble.call(this,a,m)}return a.$$set=m=>{e=assign(assign({},e),exclude_internal_props(m)),n(2,r=compute_rest_props(e,t)),"class"in m&&n(0,l=m.class),"inset"in m&&n(1,c=m.inset),"$$scope"in m&&n(11,s=m.$$scope)},[l,c,r,o,f,h,u,i,d,p,_,s]}class Context_menu_item extends SvelteComponent{constructor(e){super(),init(this,e,instance$I,create_fragment$E,safe_not_equal,{class:0,inset:1})}}function create_default_slot$j(a){let e;const n=a[4].default,t=create_slot(n,a,a[6],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&64)&&update_slot_base(t,n,r,r[6],e?get_slot_changes(n,r[6],o,null):get_all_dirty_from_scope(r[6]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$D(a){let e,n;const t=[{transition:a[1]},{transitionConfig:a[2]},{class:cn("z-50 min-w-[8rem] rounded-md border bg-popover p-1 text-popover-foreground shadow-md focus:outline-none",a[0])},a[3]];let r={$$slots:{default:[create_default_slot$j]},$$scope:{ctx:a}};for(let o=0;o<t.length;o+=1)r=assign(r,t[o]);return e=new ContextMenuContent({props:r}),e.$on("keydown",a[5]),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,[s]){const l=s&15?get_spread_update(t,[s&2&&{transition:o[1]},s&4&&{transitionConfig:o[2]},s&1&&{class:cn("z-50 min-w-[8rem] rounded-md border bg-popover p-1 text-popover-foreground shadow-md focus:outline-none",o[0])},s&8&&get_spread_object(o[3])]):{};s&64&&(l.$$scope={dirty:s,ctx:o}),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function instance$H(a,e,n){const t=["class","transition","transitionConfig"];let r=compute_rest_props(e,t),{$$slots:o={},$$scope:s}=e,{class:l=void 0}=e,{transition:c=flyAndScale}=e,{transitionConfig:f=void 0}=e;function h(u){bubble.call(this,a,u)}return a.$$set=u=>{e=assign(assign({},e),exclude_internal_props(u)),n(3,r=compute_rest_props(e,t)),"class"in u&&n(0,l=u.class),"transition"in u&&n(1,c=u.transition),"transitionConfig"in u&&n(2,f=u.transitionConfig),"$$scope"in u&&n(6,s=u.$$scope)},[l,c,f,r,o,h,s]}class Context_menu_content extends SvelteComponent{constructor(e){super(),init(this,e,instance$H,create_fragment$D,safe_not_equal,{class:0,transition:1,transitionConfig:2})}}const Root=ContextMenu,Trigger=ContextMenuTrigger,prerender=!1,ssr=!1,_page=Object.freeze(Object.defineProperty({__proto__:null,prerender,ssr},Symbol.toStringTag,{value:"Module"}));function create_fragment$C(a){let e,n,t,r,o,s;return{c(){e=svg_element("svg"),n=svg_element("g"),t=svg_element("rect"),r=svg_element("rect"),o=svg_element("rect"),s=svg_element("rect"),this.h()},l(l){e=claim_svg_element(l,"svg",{xmlns:!0,version:!0,viewBox:!0,class:!0,fill:!0});var c=children(e);n=claim_svg_element(c,"g",{"stroke-width":!0,fill:!0,"stroke-linecap":!0});var f=children(n);t=claim_svg_element(f,"rect",{fill:!0,x:!0,y:!0,transform:!0,width:!0,height:!0,rx:!0}),children(t).forEach(detach),r=claim_svg_element(f,"rect",{fill:!0,x:!0,y:!0,width:!0,height:!0,rx:!0}),children(r).forEach(detach),o=claim_svg_element(f,"rect",{fill:!0,x:!0,y:!0,transform:!0,width:!0,height:!0,rx:!0}),children(o).forEach(detach),s=claim_svg_element(f,"rect",{fill:!0,x:!0,y:!0,transform:!0,width:!0,height:!0,rx:!0}),children(s).forEach(detach),f.forEach(detach),c.forEach(detach),this.h()},h(){attr(t,"fill","currentColor"),attr(t,"x","-5.92"),attr(t,"y","-4.01"),attr(t,"transform","translate(27.13,84.71) rotate(43.3)"),attr(t,"width","11.84"),attr(t,"height","8.02"),attr(t,"rx","0.52"),attr(r,"fill","currentColor"),attr(r,"x","15.28"),attr(r,"y","95.80"),attr(r,"width","14.22"),attr(r,"height","7.96"),attr(r,"rx","0.31"),attr(o,"fill","currentColor"),attr(o,"x","-6.46"),attr(o,"y","-4.02"),attr(o,"transform","translate(27.39,116.33) rotate(-43.7)"),attr(o,"width","12.92"),attr(o,"height","8.04"),attr(o,"rx","0.56"),attr(s,"fill","currentColor"),attr(s,"x","-4.00"),attr(s,"y","-7.13"),attr(s,"transform","translate(42.50,119.88) rotate(-0.2)"),attr(s,"width","8.00"),attr(s,"height","14.26"),attr(s,"rx","0.27"),attr(n,"stroke-width","2.00"),attr(n,"fill","none"),attr(n,"stroke-linecap","butt"),attr(e,"xmlns","http://www.w3.org/2000/svg"),attr(e,"version","1.1"),attr(e,"viewBox","0.00 0.00 124.00 144.00"),attr(e,"class","absolute top-[-6px] left-[-3px]"),attr(e,"fill","#2a3039")},m(l,c){insert_hydration(l,e,c),append_hydration(e,n),append_hydration(n,t),append_hydration(n,r),append_hydration(n,o),append_hydration(n,s)},p:noop,i:noop,o:noop,d(l){l&&detach(e)}}}class MagicIcon extends SvelteComponent{constructor(e){super(),init(this,e,null,create_fragment$C,safe_not_equal,{})}}const panTool={name:"Move image",type:"PAN",cursor:"move"},rectangleTool={name:"Create a bounding box",type:"RECTANGLE",cursor:"crosshair",isSmart:!1},polygonTool={name:"Create a polygon",type:"POLYGON",cursor:"crosshair",isSmart:!1},removeSmartPointTool={name:"Negative point selection",type:"POINT_SELECTION",cursor:"crosshair",label:0,isSmart:!0},addSmartPointTool={name:"Positive point selection",type:"POINT_SELECTION",cursor:"crosshair",label:1,isSmart:!0},smartRectangleTool={name:"Rectangle selection",type:"RECTANGLE",cursor:"crosshair",isSmart:!0};function maskDataToFortranArrayToRle(a,e,n){const t=[];let r=0,o=!1;for(let s=0;s<n;s++)for(let l=0;l<e;l++){const c=s+l*n;c<a.length&&(a[c]>0!==o?(t.push(r),o=!o,r=1):r++)}return r>0&&t.push(r),t}function splitPointKey(a){return a.split(" ").map(e=>parseInt(e))}function getLineBreakpoints(a,e){const n=[],t={line:-1,points:[]};let r=0;const o=()=>{t.points.length>0&&(n.push({line:t.line,points:t.points}),t.points=[])};for(let s=1;s<a.length;s+=2){r+=a[s-1];const l=r%e,c=Math.floor(r/e);r+=a[s];const f=r%e,h=Math.floor(r/e);if(t.line!==c&&(o(),t.line=c),c===h){t.points.push(l,f);continue}t.points.push(l,e),o(),t.line=h;for(let u=c+1;u<h;u++)n.push({line:u,points:[0,e]});f>0&&t.points.push(0,f)}return o(),n}function generatePolygonSegments(a,e){const n=getLineBreakpoints(a,e);if(n.length===0)return new Map;const t=new Map;let r=-1,o=[];const s=new Map,l=(i,d)=>{const p=`${i.x} ${i.y}`,_=`${d.x} ${d.y}`;t.has(p)||t.set(p,new Set),t.get(p).add(_),t.has(_)||t.set(_,new Set),t.get(_).add(p)},c=(i,d)=>{d!==s.get(i)&&(l({x:s.get(i),y:i},{x:d,y:i}),s.delete(i))},f=(i,d,p,_)=>{if(d===_){s.has(d)||s.set(d,i);return}let m=!1;const g=Math.max(i,p);s.has(d)&&(c(d,g),m=!0),s.has(_)&&(c(_,g),m=!0),m?l({x:g,y:d},{x:g,y:_}):l({x:i,y:d},{x:p,y:_})},h=(i,d)=>{for(const p of d)f(i,p,i+1,p);for(let p=1;p<d.length;p+=2)f(i+1,d[p-1],i+1,d[p])};for(const{line:i,points:d}of n){i!==r+1&&(h(r,o),r=i-1,o=[]);let p=o.length&&o[0]<=d[0]?r:i,_=p===r?o[0]:d[0],m=p===r?1:0,g=p===r?0:1,b=!0;for(;m<o.length||g<d.length;){let v,T;m===o.length||d[g]<o[m]?(v=i,T=d[g],g++):(v=r,T=o[m],m++),b&&(p===r&&v===r?(f(r,_,i,_),f(r,T,i,T),f(i,_,i,T)):f(p,_,v,T)),b=!b,p=v,_=T}r=i,o=d}return h(r,o),new Map([...t].sort((i,d)=>{const[p,_]=splitPointKey(i[0]),[m,g]=splitPointKey(d[0]);return p===m?_-g:p-m}))}function convertSegmentsToSVG(a){const e=[];for(;a.size;){let[s,l]=a.entries().next().value;const c=s,f=[splitPointKey(c)];let h="";for(;h!==c;){h=l.values().next().value,f.push(splitPointKey(h)),l.delete(h),l.size===0&&a.delete(s);const u=a.get(h);if(u==null||u.delete(s),(u==null?void 0:u.size)===0){a.delete(h);break}else s=h,u&&(l=u)}e.push(f)}const n=[],t=[],o=document.createElement("canvas").getContext("2d");for(const s of e){let l=!1;const[c,f]=s[0];for(const d of n)o!=null&&o.isPointInPath(d,c+.5,f+.5)&&(l=!l);l&&s.reverse();const h=s.slice(1).map(([d,p])=>`${d} ${p}`).join(" "),u=`M${s[0][0]} ${s[0][1]} L`+h;t.push(u);const i=new Path2D(u);o==null||o.fill(i),n.push(i)}return t}/**
 * @copyright CEA
 * @author CEA
 * @license CECILL
 *
 * This software is a collaborative computer program whose purpose is to
 * generate and explore labeled data for computer vision applications.
 * This software is governed by the CeCILL-C license under French law and
 * abiding by the rules of distribution of free software. You can use,
 * modify and/ or redistribute the software under the terms of the CeCILL-C
 * license as circulated by CEA, CNRS and INRIA at the following URL
 *
 * http://www.cecill.info
 */const dtypes={"<u1":{name:"uint8",size:8,arrayConstructor:Uint8Array},"|u1":{name:"uint8",size:8,arrayConstructor:Uint8Array},"<u2":{name:"uint16",size:16,arrayConstructor:Uint16Array},"|i1":{name:"int8",size:8,arrayConstructor:Int8Array},"<i2":{name:"int16",size:16,arrayConstructor:Int16Array},"<u4":{name:"uint32",size:32,arrayConstructor:Int32Array},"<i4":{name:"int32",size:32,arrayConstructor:Int32Array},"<u8":{name:"uint64",size:64,arrayConstructor:BigUint64Array},"<i8":{name:"int64",size:64,arrayConstructor:BigInt64Array},"<f4":{name:"float32",size:32,arrayConstructor:Float32Array},"<f8":{name:"float64",size:64,arrayConstructor:Float64Array}};function parse(a){const e=new Uint8Array(a);if(e[6]!=1)throw"Only npy version 1 is supported";const n=e[8]+e[9]*256,t=10+n,r=JSON.parse(new TextDecoder("utf-8").decode(e.slice(10,10+n)).replace(/'/g,'"').replace("False","false").replace("(","[").replace(/,*\),*/g,"]"));if(r.fortan_order)throw"Fortran-contiguous array data are not supported";const o=dtypes[r.descr];return{data:new o.arrayConstructor(e.slice(t).buffer),shape:r.shape,dtype:o.name}}function b64ToBuffer(a){const e=atob(a),n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n.buffer}var ort_min={exports:{}};/*!
* ONNX Runtime Web v1.16.3
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/(function(module,exports){(function(a,e){module.exports=e()})(self,()=>(()=>{var __webpack_modules__={5716:(a,e,n)=>{e.R=void 0;const t=n(6027),r=n(1723);e.R=new class{async init(){}async createSessionHandler(o,s){const l=new t.Session(s);return await l.loadModel(o),new r.OnnxjsSessionHandler(l)}}},2818:(a,e,n)=>{e.c8=e.rX=void 0;const t=n(2235),r=n(5381),o=n(9544),s=n(6640);e.rX=()=>{if((typeof t.env.wasm.initTimeout!="number"||t.env.wasm.initTimeout<0)&&(t.env.wasm.initTimeout=0),typeof t.env.wasm.simd!="boolean"&&(t.env.wasm.simd=!0),typeof t.env.wasm.proxy!="boolean"&&(t.env.wasm.proxy=!1),typeof t.env.wasm.numThreads!="number"||!Number.isInteger(t.env.wasm.numThreads)||t.env.wasm.numThreads<=0){const l=typeof navigator>"u"?(0,r.cpus)().length:navigator.hardwareConcurrency;t.env.wasm.numThreads=Math.min(4,Math.ceil((l||1)/2))}},e.c8=new class{async init(){(0,e.rX)(),await(0,o.initializeWebAssemblyInstance)()}async createSessionHandler(l,c){const f=new s.OnnxruntimeWebAssemblySessionHandler;return await f.loadModel(l,c),Promise.resolve(f)}}},1057:function(a,e,n){var t=this&&this.__createBinding||(Object.create?function(l,c,f,h){h===void 0&&(h=f);var u=Object.getOwnPropertyDescriptor(c,f);u&&!("get"in u?!c.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return c[f]}}),Object.defineProperty(l,h,u)}:function(l,c,f,h){h===void 0&&(h=f),l[h]=c[f]}),r=this&&this.__exportStar||function(l,c){for(var f in l)f==="default"||Object.prototype.hasOwnProperty.call(c,f)||t(c,l,f)};Object.defineProperty(e,"__esModule",{value:!0}),r(n(2235),e);const o=n(2235),s=n(8408);{const l=n(5716).R;(0,o.registerBackend)("webgl",l,-10)}{const l=n(2818).c8;(0,o.registerBackend)("cpu",l,10),(0,o.registerBackend)("wasm",l,10),(0,o.registerBackend)("xnnpack",l,9),(0,o.registerBackend)("webnn",l,9)}o.env.versions.web=s.version},4910:(a,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createAttributeWithCacheKey=void 0;class n{constructor(r){Object.assign(this,r)}get cacheKey(){return this._cacheKey||(this._cacheKey=Object.getOwnPropertyNames(this).sort().map(r=>`${this[r]}`).join(";")),this._cacheKey}}e.createAttributeWithCacheKey=t=>new n(t)},6874:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Attribute=void 0;const t=n(5127),r=n(2446),o=n(9240),s=n(7273);var l=t.onnxruntime.experimental.fbs;class c{constructor(h){if(this._attributes=new Map,h!=null){for(const u of h)u instanceof r.onnx.AttributeProto?this._attributes.set(u.name,[c.getValue(u),c.getType(u)]):u instanceof l.Attribute&&this._attributes.set(u.name(),[c.getValue(u),c.getType(u)]);if(this._attributes.size<h.length)throw new Error("duplicated attribute names")}}set(h,u,i){this._attributes.set(h,[i,u])}delete(h){this._attributes.delete(h)}getFloat(h,u){return this.get(h,"float",u)}getInt(h,u){return this.get(h,"int",u)}getString(h,u){return this.get(h,"string",u)}getTensor(h,u){return this.get(h,"tensor",u)}getFloats(h,u){return this.get(h,"floats",u)}getInts(h,u){return this.get(h,"ints",u)}getStrings(h,u){return this.get(h,"strings",u)}getTensors(h,u){return this.get(h,"tensors",u)}get(h,u,i){const d=this._attributes.get(h);if(d===void 0){if(i!==void 0)return i;throw new Error(`required attribute not found: ${h}`)}if(d[1]!==u)throw new Error(`type mismatch: expected ${u} but got ${d[1]}`);return d[0]}static getType(h){const u=h instanceof r.onnx.AttributeProto?h.type:h.type();switch(u){case r.onnx.AttributeProto.AttributeType.FLOAT:return"float";case r.onnx.AttributeProto.AttributeType.INT:return"int";case r.onnx.AttributeProto.AttributeType.STRING:return"string";case r.onnx.AttributeProto.AttributeType.TENSOR:return"tensor";case r.onnx.AttributeProto.AttributeType.FLOATS:return"floats";case r.onnx.AttributeProto.AttributeType.INTS:return"ints";case r.onnx.AttributeProto.AttributeType.STRINGS:return"strings";case r.onnx.AttributeProto.AttributeType.TENSORS:return"tensors";default:throw new Error(`attribute type is not supported yet: ${r.onnx.AttributeProto.AttributeType[u]}`)}}static getValue(h){const u=h instanceof r.onnx.AttributeProto?h.type:h.type();if(u===r.onnx.AttributeProto.AttributeType.GRAPH||u===r.onnx.AttributeProto.AttributeType.GRAPHS)throw new Error("graph attribute is not supported yet");const i=this.getValueNoCheck(h);if(u===r.onnx.AttributeProto.AttributeType.INT&&s.LongUtil.isLong(i))return s.LongUtil.longToNumber(i);if(u===r.onnx.AttributeProto.AttributeType.INTS){const d=i,p=new Array(d.length);for(let _=0;_<d.length;_++){const m=d[_];p[_]=s.LongUtil.longToNumber(m)}return p}if(u===r.onnx.AttributeProto.AttributeType.TENSOR)return h instanceof r.onnx.AttributeProto?o.Tensor.fromProto(i):o.Tensor.fromOrtTensor(i);if(u===r.onnx.AttributeProto.AttributeType.TENSORS){if(h instanceof r.onnx.AttributeProto)return i.map(d=>o.Tensor.fromProto(d));if(h instanceof l.Attribute)return i.map(d=>o.Tensor.fromOrtTensor(d))}if(u===r.onnx.AttributeProto.AttributeType.STRING&&h instanceof r.onnx.AttributeProto){const d=i;return(0,s.decodeUtf8String)(d)}return u===r.onnx.AttributeProto.AttributeType.STRINGS&&h instanceof r.onnx.AttributeProto?i.map(s.decodeUtf8String):i}static getValueNoCheck(h){return h instanceof r.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(h):this.getValueNoCheckFromOrtFormat(h)}static getValueNoCheckFromOnnxFormat(h){switch(h.type){case r.onnx.AttributeProto.AttributeType.FLOAT:return h.f;case r.onnx.AttributeProto.AttributeType.INT:return h.i;case r.onnx.AttributeProto.AttributeType.STRING:return h.s;case r.onnx.AttributeProto.AttributeType.TENSOR:return h.t;case r.onnx.AttributeProto.AttributeType.GRAPH:return h.g;case r.onnx.AttributeProto.AttributeType.FLOATS:return h.floats;case r.onnx.AttributeProto.AttributeType.INTS:return h.ints;case r.onnx.AttributeProto.AttributeType.STRINGS:return h.strings;case r.onnx.AttributeProto.AttributeType.TENSORS:return h.tensors;case r.onnx.AttributeProto.AttributeType.GRAPHS:return h.graphs;default:throw new Error(`unsupported attribute type: ${r.onnx.AttributeProto.AttributeType[h.type]}`)}}static getValueNoCheckFromOrtFormat(h){switch(h.type()){case l.AttributeType.FLOAT:return h.f();case l.AttributeType.INT:return h.i();case l.AttributeType.STRING:return h.s();case l.AttributeType.TENSOR:return h.t();case l.AttributeType.GRAPH:return h.g();case l.AttributeType.FLOATS:return h.floatsArray();case l.AttributeType.INTS:{const u=[];for(let i=0;i<h.intsLength();i++)u.push(h.ints(i));return u}case l.AttributeType.STRINGS:{const u=[];for(let i=0;i<h.stringsLength();i++)u.push(h.strings(i));return u}case l.AttributeType.TENSORS:{const u=[];for(let i=0;i<h.tensorsLength();i++)u.push(h.tensors(i));return u}default:throw new Error(`unsupported attribute type: ${l.AttributeType[h.type()]}`)}}}e.Attribute=c},1975:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveBackend=e.backend=void 0;const t=n(4418),r=new Map;async function o(s){const l=e.backend;if(l[s]!==void 0&&function(c){const f=c;return"initialize"in f&&typeof f.initialize=="function"&&"createSessionHandler"in f&&typeof f.createSessionHandler=="function"&&"dispose"in f&&typeof f.dispose=="function"}(l[s])){const c=l[s];let f=c.initialize();if(typeof f=="object"&&"then"in f&&(f=await f),f)return r.set(s,c),c}}e.backend={webgl:new t.WebGLBackend},e.resolveBackend=async function s(l){if(!l)return s(["webgl"]);{const c=typeof l=="string"?[l]:l;for(const f of c){const h=r.get(f);if(h)return h;const u=await o(f);if(u)return u}}throw new Error("no available backend to use")}},4418:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLBackend=void 0;const t=n(2235),r=n(1315),o=n(2171),s=n(3389);e.WebGLBackend=class{get contextId(){return t.env.webgl.contextId}set contextId(l){t.env.webgl.contextId=l}get matmulMaxBatchSize(){return t.env.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(l){t.env.webgl.matmulMaxBatchSize=l}get textureCacheMode(){return t.env.webgl.textureCacheMode}set textureCacheMode(l){t.env.webgl.textureCacheMode=l}get pack(){return t.env.webgl.pack}set pack(l){t.env.webgl.pack=l}get async(){return t.env.webgl.async}set async(l){t.env.webgl.async=l}initialize(){try{return this.glContext=(0,s.createWebGLContext)(this.contextId),typeof this.matmulMaxBatchSize!="number"&&(this.matmulMaxBatchSize=16),typeof this.textureCacheMode!="string"&&(this.textureCacheMode="full"),typeof this.pack!="boolean"&&(this.pack=!1),typeof this.async!="boolean"&&(this.async=!1),r.Logger.setWithEnv(t.env),r.Logger.verbose("WebGLBackend",`Created WebGLContext: ${typeof this.glContext} with matmulMaxBatchSize: ${this.matmulMaxBatchSize}; textureCacheMode: ${this.textureCacheMode}; pack: ${this.pack}; async: ${this.async}.`),!0}catch(l){return r.Logger.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${l}`),!1}}createSessionHandler(l){return new o.WebGLSessionHandler(this,l)}dispose(){this.glContext.dispose()}}},6859:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CoordsGlslLib=void 0;const t=n(7273),r=n(1997),o=n(6757),s=n(7618),l=n(432);class c extends r.GlslLib{constructor(h){super(h)}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.offsetToCoords()),this.coordsToOffset()),this.toVec()),this.valueFrom()),this.getCommonUtilFuncs()),this.getInputsSamplingSnippets()),this.getOutputSamplingSnippet())}getCustomTypes(){return{}}offsetToCoords(){return{offsetToCoords:new r.GlslLibRoutine(`
      vec2 offsetToCoords(int offset, int width, int height) {
        int t = offset / width;
        int s = offset - t*width;
        vec2 coords = (vec2(s,t) + vec2(0.5,0.5)) / vec2(width, height);
        return coords;
      }
      `)}}coordsToOffset(){return{coordsToOffset:new r.GlslLibRoutine(`
      int coordsToOffset(vec2 coords, int width, int height) {
        float s = coords.s * float(width);
        float t = coords.t * float(height);
        int offset = int(t) * width + int(s);
        return offset;
      }
      `)}}getOutputSamplingSnippet(){const h=this.context.outputTextureLayout;return h.isPacked?this.getPackedOutputSamplingSnippet(h):this.getUnpackedOutputSamplingSnippet(h)}getPackedOutputSamplingSnippet(h){const u=h.unpackedShape,i=[h.width,h.height],d={},p="getOutputCoords";switch(u.length){case 0:d[p]=this.getOutputScalarCoords();break;case 1:d[p]=this.getOutputPacked1DCoords(u,i);break;case 2:d[p]=this.getOutputPacked2DCoords(u,i);break;case 3:d[p]=this.getOutputPacked3DCoords(u,i);break;default:d[p]=this.getOutputPackedNDCoords(u,i)}const _=`
      void setOutput(vec4 val) {
        ${(0,o.getGlsl)(this.context.glContext.version).output} = val;
      }
    `;return d.floatTextureSetRGBA=new r.GlslLibRoutine(_),d}getUnpackedOutputSamplingSnippet(h){const u=h.unpackedShape,i=[h.width,h.height],d={},p="getOutputCoords";switch(u.length){case 0:d[p]=this.getOutputScalarCoords();break;case 1:d[p]=this.getOutputUnpacked1DCoords(u,i);break;case 2:d[p]=this.getOutputUnpacked2DCoords(u,i);break;case 3:d[p]=this.getOutputUnpacked3DCoords(u,i);break;case 4:d[p]=this.getOutputUnpacked4DCoords(u,i);break;case 5:d[p]=this.getOutputUnpacked5DCoords(u,i);break;case 6:d[p]=this.getOutputUnpacked6DCoords(u,i);break;default:throw new Error(`Unsupported output dimensionality: ${u.length}`)}const _=`
        void setOutput(float val) {
          ${(0,o.getGlsl)(this.context.glContext.version).output} = vec4(val, 0, 0, 0);
        }
    `;return d.floatTextureSetR=new r.GlslLibRoutine(_),d}getOutputScalarCoords(){return new r.GlslLibRoutine(`
      int getOutputCoords() {
        return 0;
      }
    `)}getOutputPacked1DCoords(h,u){const i=u;let d="";return i[0]===1?(d=`
          int getOutputCoords() {
            return 2 * int(TexCoords.y * ${i[1]}.0);
          }
        `,new r.GlslLibRoutine(d)):i[1]===1?(d=`
          int getOutputCoords() {
            return 2 * int(TexCoords.x * ${i[0]}.0);
          }
        `,new r.GlslLibRoutine(d)):(d=`
        int getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                 vec2(${i[0]}, ${i[1]}));
          return 2 * (resTexRC.y * ${i[0]} + resTexRC.x);
        }
      `,new r.GlslLibRoutine(d))}getOutputPacked2DCoords(h,u){let i="";if(t.ArrayUtil.arraysEqual(h,u))return i=`
        ivec2 getOutputCoords() {
          return 2 * ivec2(TexCoords.xy * vec2(${u[0]}, ${u[1]}));
        }
      `,new r.GlslLibRoutine(i);const d=u,p=Math.ceil(h[1]/2);return i=`
        ivec2 getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${d[0]}, ${d[1]}));

          int index = resTexRC.y * ${d[0]} + resTexRC.x;

          // reverse r and c order for packed texture
          int r = imod(index, ${p}) * 2;
          int c = 2 * (index / ${p});

          return ivec2(r, c);
        }
      `,new r.GlslLibRoutine(i)}getOutputPacked3DCoords(h,u){const i=[u[0],u[1]],d=Math.ceil(h[2]/2),p=d*Math.ceil(h[1]/2),_=`
        ivec3 getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${i[0]}, ${i[1]}));
          int index = resTexRC.y * ${i[0]} + resTexRC.x;

          int b = index / ${p};
          index -= b * ${p};

          // reverse r and c order for packed texture
          int r = imod(index, ${d}) * 2;
          int c = 2 * (index / ${d});

          return ivec3(b, r, c);
        }
      `;return new r.GlslLibRoutine(_)}getOutputPackedNDCoords(h,u){const i=[u[0],u[1]],d=Math.ceil(h[h.length-1]/2),p=d*Math.ceil(h[h.length-2]/2);let _=p,m="",g="b, r, c";for(let v=2;v<h.length-1;v++)_*=h[h.length-v-1],m=`
      int b${v} = index / ${_};
      index -= b${v} * ${_};
    `+m,g=`b${v}, `+g;const b=`
      ivec${h.length} getOutputCoords() {
        ivec2 resTexRC = ivec2(TexCoords.xy *
                              vec2(${i[0]}, ${i[1]}));
        int index = resTexRC.y * ${i[0]} + resTexRC.x;

        ${m}

        int b = index / ${p};
        index -= b * ${p};

        // reverse r and c order for packed texture
        int r = imod(index, ${d}) * 2;
        int c = 2 * (index / ${d});

        return ivec${h.length}(${g});
      }
    `;return new r.GlslLibRoutine(b)}getOutputUnpacked1DCoords(h,u){const i=`
        int getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${u[0]}, ${u[1]}));
          return resTexRC.y * ${u[0]} + resTexRC.x;
        }
      `;return new r.GlslLibRoutine(i)}getOutputUnpacked2DCoords(h,u){const i=`
        ivec2 getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${u[0]}, ${u[1]}));
          int index = resTexRC.y * ${u[0]} + resTexRC.x;
          int r = index / ${h[1]};
          int c = index - r * ${h[1]};
          return ivec2(r, c);
        }
      `;return new r.GlslLibRoutine(i)}getOutputUnpacked3DCoords(h,u){let i="";const d=h.length;let p=null;d<2&&(p=[]),p=new Array(d-1),p[d-2]=h[d-1];for(let g=d-3;g>=0;--g)p[g]=p[g+1]*h[g+1];const _=["r","c","d"],m=p.map((g,b)=>`int ${_[b]} = index / ${g}; ${b===p.length-1?`int ${_[b+1]} = index - ${_[b]} * ${g}`:`index -= ${_[b]} * ${g}`};`).join("");return i=`
        ivec3 getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${u[0]}, ${u[1]}));
          int index = resTexRC.y * ${u[0]} + resTexRC.x;
          ${m}
          return ivec3(r, c, d);
        }
      `,new r.GlslLibRoutine(i)}getOutputUnpacked4DCoords(h,u){let i="";const d=h.length;let p=null;d<2&&(p=[]),p=new Array(d-1),p[d-2]=h[d-1];for(let g=d-3;g>=0;--g)p[g]=p[g+1]*h[g+1];const _=["r","c","d","d2"],m=p.map((g,b)=>`int ${_[b]} = index / ${g}; ${b===p.length-1?`int ${_[b+1]} = index - ${_[b]} * ${g}`:`index -= ${_[b]} * ${g}`};`).join("");return i=`
      ivec4 getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${u[0]}, ${u[1]}));
          int index = resTexRC.y * ${u[0]} + resTexRC.x;
          ${m}
          return ivec4(r, c, d, d2);
        }
      `,new r.GlslLibRoutine(i)}getOutputUnpacked5DCoords(h,u){let i="";const d=h.length;let p=null;d<2&&(p=[]),p=new Array(d-1),p[d-2]=h[d-1];for(let g=d-3;g>=0;--g)p[g]=p[g+1]*h[g+1];const _=["r","c","d","d2","d3"],m=p.map((g,b)=>`int ${_[b]} = index / ${g}; ${b===p.length-1?`int ${_[b+1]} = index - ${_[b]} * ${g}`:`index -= ${_[b]} * ${g}`};`).join("");return i=`
      ivec5 getOutputCoords() {
          ivec2 resTexRC = ivec2(TexCoords.xy *
                                vec2(${u[0]}, ${u[1]}));
          int index = resTexRC.y * ${u[0]} + resTexRC.x;
          ${m}
          return ivec5(r, c, d, d2, d3);
        }
      `,new r.GlslLibRoutine(i)}getOutputUnpacked6DCoords(h,u){let i="";const d=h.length;let p=null;d<2&&(p=[]),p=new Array(d-1),p[d-2]=h[d-1];for(let g=d-3;g>=0;--g)p[g]=p[g+1]*h[g+1];const _=["r","c","d","d2","d3","d4"],m=p.map((g,b)=>`int ${_[b]} = index / ${g}; ${b===p.length-1?`int ${_[b+1]} = index - ${_[b]} * ${g}`:`index -= ${_[b]} * ${g}`};`).join("");return i=`
     ivec6 getOutputCoords() {
         ivec2 resTexRC = ivec2(TexCoords.xy *
                               vec2(${u[0]}, ${u[1]}));
         int index = resTexRC.y * ${u[0]} + resTexRC.x;
         ${m}
         return ivec6(r, c, d, d2, d3, d4);
       }
     `,new r.GlslLibRoutine(i)}getCommonUtilFuncs(){const h={};let u="uvFromFlat";h[u]=new r.GlslLibRoutine(`
    vec2 uvFromFlat(int texNumR, int texNumC, int index) {
      int texC = index / texNumR;
      int texR = index - texC * texNumR;
      // TODO: swap texR, texC order in following function so row is corresponding to u and column is corresponding to
      //       v.
      return (vec2(texR, texC) + halfCR) / vec2(texNumR, texNumC);
    }
    `),u="packedUVfrom1D",h[u]=new r.GlslLibRoutine(`
      vec2 packedUVfrom1D(int texNumR, int texNumC, int index) {
        int texelIndex = index / 2;
        int texR = texelIndex / texNumC;
        int texC = texelIndex - texR * texNumC;
        return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
      }
      `),u="packedUVfrom2D",h[u]=new r.GlslLibRoutine(`
      vec2 packedUVfrom2D(int texNumR, int texNumC, int texelsInLogicalRow, int row, int col) {
        int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);
        int texR = texelIndex / texNumC;
        int texC = texelIndex - texR * texNumC;
        return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
      }
      `),u="packedUVfrom3D",h[u]=new r.GlslLibRoutine(`
      vec2 packedUVfrom3D(int texNumR, int texNumC,
          int texelsInBatch, int texelsInLogicalRow, int b,
          int row, int col) {
        int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);
        int texR = index / texNumC;
        int texC = index - texR * texNumC;
        return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
      }
      `),u="sampleTexture";const i=(0,o.getGlsl)(this.context.glContext.version);return h[u]=new r.GlslLibRoutine(`
        float sampleTexture(sampler2D textureSampler, vec2 uv) {
            return ${i.texture2D}(textureSampler, uv).r;
        }`),h}getInputsSamplingSnippets(){const h={},u=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach((i,d)=>{const p=this.context.inputTextureLayouts[d],_=(0,l.generateShaderFuncNameFromInputSamplerName)(i);p.isPacked?h[_]=this.getPackedSamplerFromInput(_,i,p):h[_]=this.getUnpackedSamplerFromInput(_,i,p);const m=(0,l.generateShaderFuncNameFromInputSamplerNameAtOutCoords)(i);p.unpackedShape.length<=u.unpackedShape.length&&(p.isPacked?h[m]=this.getPackedSamplerAtOutputCoords(m,p,u,i):h[m]=this.getUnpackedSamplerAtOutputCoords(m,p,u,i))}),h}getPackedSamplerAtOutputCoords(h,u,i,d){const p=u.unpackedShape,_=i.unpackedShape,m=d,g=(0,l.generateShaderFuncNameFromInputSamplerName)(m),b=p.length,v=_.length,T=t.BroadcastUtil.getBroadcastDims(p,_),y=(0,l.getCoordsDataType)(v),w=v-b;let S;const O=(0,l.getGlChannels)();S=b===0?"":v<2&&T.length>=1?"coords = 0;":T.map(D=>`coords.${O[D+w]} = 0;`).join(`
`);let P="";P=v<2&&b>0?"coords":p.map((D,I)=>`coords.${O[I+w]}`).join(", ");let E="return outputValue;";const A=t.ShapeUtil.size(p)===1,$=t.ShapeUtil.size(_)===1;if(b!==1||A||$){if(A&&!$)E=v===1?`
          return vec4(outputValue.x, outputValue.x, 0., 0.);
        `:`
          return vec4(outputValue.x);
        `;else if(T.length){const D=b-2,I=b-1;T.indexOf(D)>-1&&T.indexOf(I)>-1?E="return vec4(outputValue.x);":T.indexOf(D)>-1?E="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":T.indexOf(I)>-1&&(E="return vec4(outputValue.xx, outputValue.zz);")}}else E=`
        return vec4(outputValue.xy, outputValue.xy);
      `;const k=`
      vec4 ${h}() {
        ${y} coords = getOutputCoords();
        
        int lastDim = coords.${O[v-1]};
        coords.${O[v-1]} = coords.${O[v-2]};
        coords.${O[v-2]} = lastDim;
      
        ${S}
        vec4 outputValue = ${g}(${P});
        ${E}
      }
    `;return new r.GlslLibRoutine(k,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(h,u,i,d){const p=[i.width,i.height],_=[u.width,u.height],m=u.unpackedShape.length,g=i.unpackedShape.length,b=u.unpackedShape,v=i.unpackedShape,T=(0,l.generateShaderFuncNameFromInputSamplerName)(d);if(m===g&&t.ArrayUtil.arraysEqual(_,p)){const $=`
          float ${h}() {
            return sampleTexture(${d}, TexCoords);
          }
        `;return new r.GlslLibRoutine($,["coordinates.sampleTexture"])}const y=(0,l.getCoordsDataType)(g),w=t.BroadcastUtil.getBroadcastDims(b,v),S=g-m;let O;const P=(0,l.getGlChannels)();O=m===0?"":g<2&&w.length>=1?"coords = 0;":w.map($=>`coords.${P[$+S]} = 0;`).join(`
`);let E="";E=g<2&&m>0?"coords":u.unpackedShape.map(($,k)=>`coords.${P[k+S]}`).join(", ");const A=`
        float ${h}() {
          ${y} coords = getOutputCoords();
          ${O}
          return ${T}(${E});
        }
      `;return new r.GlslLibRoutine(A,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(h,u,i){switch(i.unpackedShape.length){case 0:return this.getPackedSamplerScalar(h,u);case 1:return this.getPackedSampler1D(h,u,i);case 2:return this.getPackedSampler2D(h,u,i);case 3:return this.getPackedSampler3D(h,u,i);default:return this.getPackedSamplerND(h,u,i)}}getUnpackedSamplerFromInput(h,u,i){const d=i.unpackedShape;switch(d.length){case 0:return this.getUnpackedSamplerScalar(h,u,i);case 1:return this.getUnpackedSampler1D(h,u,i);case 2:return this.getUnpackedSampler2D(h,u,i);case 3:return this.getUnpackedSampler3D(h,u,i);case 4:return this.getUnpackedSampler4D(h,u,i);case 5:return this.getUnpackedSampler5D(h,u,i);case 6:return this.getUnpackedSampler6D(h,u,i);default:throw new Error(`Unsupported dimension ${d.length}-D`)}}getPackedSamplerScalar(h,u){const i=`
          vec4 ${h}() {
            return ${(0,o.getGlsl)(this.context.glContext.version).texture2D}(${u}, halfCR);
          }
        `;return new r.GlslLibRoutine(i)}getPackedSampler1D(h,u,i){const d=[i.width,i.height],p=[d[1],d[0]],_=(0,o.getGlsl)(this.context.glContext.version),m=`vec4 ${h}(int index) {
      vec2 uv = packedUVfrom1D(
      ${p[0]}, ${p[1]}, index);
      return ${_.texture2D}(${u}, uv);
    }`;return new r.GlslLibRoutine(m,["coordinates.packedUVfrom1D"])}getPackedSampler2D(h,u,i){const d=i.unpackedShape,p=[i.width,i.height],_=(0,o.getGlsl)(this.context.glContext.version),m=p[0],g=p[1];if(p!=null&&t.ArrayUtil.arraysEqual(d,p)){const y=`vec4 ${h}(int row, int col) {
        vec2 uv = (vec2(col, row) + halfCR) / vec2(${g}.0, ${m}.0);
        return ${_.texture2D}(${u}, uv);
      }`;return new r.GlslLibRoutine(y)}const b=p,v=Math.ceil(d[1]/2),T=`vec4 ${h}(int row, int col) {
      vec2 uv = packedUVfrom2D(${b[1]}, ${b[0]}, ${v}, row, col);
      return ${_.texture2D}(${u}, uv);
    }`;return new r.GlslLibRoutine(T,["coordinates.packedUVfrom2D"])}getPackedSampler3D(h,u,i){const d=i.unpackedShape,p=[i.width,i.height],_=[p[0],p[1]],m=(0,o.getGlsl)(this.context.glContext.version);if(d[0]===1){const y=d.slice(1),w=[1,2],S=(0,l.squeezeInputShape)(d,y),O=["b","row","col"],P=JSON.parse(JSON.stringify(i));P.unpackedShape=S;const E=this.getPackedSamplerFromInput(h,u,P),A=`${E.routineBody}
      vec4 ${h}(int b, int row, int col) {
        return ${h}(${(0,l.getSqueezedParams)(O,w)});
      } `;return new r.GlslLibRoutine(A,E.dependencies)}const g=_[0],b=_[1],v=Math.ceil(d[2]/2),T=`vec4 ${h}(int b, int row, int col) {
      vec2 uv = packedUVfrom3D(
        ${b}, ${g}, ${v*Math.ceil(d[1]/2)}, ${v}, b, row, col);
      return ${m.texture2D}(${u}, uv);}`;return new r.GlslLibRoutine(T,["coordinates.packedUVfrom3D"])}getPackedSamplerND(h,u,i){const d=i.unpackedShape,p=d.length,_=[i.width,i.height],m=(0,o.getGlsl)(this.context.glContext.version),g=[_[0],_[1]],b=g[1],v=g[0],T=Math.ceil(d[p-1]/2);let y=T*Math.ceil(d[p-2]/2),w="int b, int row, int col",S=`b * ${y} + (row / 2) * ${T} + (col / 2)`;for(let P=2;P<p-1;P++)w=`int b${P}, `+w,y*=d[p-P-1],S=`b${P} * ${y} + `+S;const O=`vec4 ${h}(${w}) {
      int index = ${S};
      int texR = index / ${v};
      int texC = index - texR * ${v};
      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${v}, ${b});
      return ${m.texture2D}(${u}, uv);
    }`;return new r.GlslLibRoutine(O)}getUnpackedSamplerScalar(h,u,i){const[d,p]=[i.width,i.height];if(d===1&&p===1){const m=`
          float ${h}() {
            return sampleTexture(${u}, halfCR);
          }
        `;return new r.GlslLibRoutine(m,["coordinates.sampleTexture"])}const _=`
        float ${h}() {
          int offset_${u} = coordsToOffset(TexCoords, ${d}, ${p});
          vec2 uv = uvFromFlat(${d}, ${p}, offset_${u});
          return sampleTexture(${u}, uv);
        }
      `;return new r.GlslLibRoutine(_,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler1D(h,u,i){const d=i.width,p=i.height;if(p===1&&d===1){const m=`
        float ${h}(int index) {
          return sampleTexture(${u}, halfCR);
        }
      `;return new r.GlslLibRoutine(m,["coordinates.sampleTexture"])}if(p===1){const m=`
          float ${h}(int index) {
            vec2 uv = vec2((float(index) + 0.5) / ${d}.0, 0.5);
            return sampleTexture(${u}, uv);
          }
        `;return new r.GlslLibRoutine(m,["coordinates.sampleTexture"])}if(d===1){const m=`
          float ${h}(int index) {
            vec2 uv = vec2(0.5, (float(index) + 0.5) / ${p}.0);
            return sampleTexture(${u}, uv);
          }
        `;return new r.GlslLibRoutine(m,["coordinates.sampleTexture"])}const _=`
        float ${h}(int index) {
          vec2 uv = uvFromFlat(${d}, ${p}, index);
          return sampleTexture(${u}, uv);
        }
      `;return new r.GlslLibRoutine(_,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler2D(h,u,i){const d=i.unpackedShape,p=[i.height,i.width];if(p!=null&&t.ArrayUtil.arraysEqual(d,p)){const y=`
          float ${h}(int row, int col) {
            vec2 uv = (vec2(row, col) + halfCR) / vec2(${p[1]}.0, ${p[0]}.0);
            return sampleTexture(${u}, uv);
          }
        `;return new r.GlslLibRoutine(y,["coordinates.sampleTexture"])}const{newShape:_,keptDims:m}=(0,s.squeezeShape)(d),g=_;if(g.length<d.length){const y=(0,l.squeezeInputShape)(d,g),w=JSON.parse(JSON.stringify(i));w.unpackedShape=y;const S=["col","row"],O=`
          ${this.getUnpackedSamplerFromInput(h,u,w).routineBody}
          float ${h}(int row, int col) {
            return ${h}(${(0,l.getSqueezedParams)(S,m)});
          }
        `;return new r.GlslLibRoutine(O,["coordinates.sampleTexture"])}const b=p[1],v=p[0];if(v===1){const y=`
          float ${h}(int row, int col) {
            int offset_${u} = coordsToOffset(TexCoords, ${b}, ${v});
            float index = dot(vec3(row, col, offset_${u}), vec3(${d[1]}, 1, 1));
            vec2 uv = vec2(0.5, (index + 0.5) / ${b}.0);
            return sampleTexture(${u}, uv);
          }
        `;return new r.GlslLibRoutine(y,["coordinates.sampleTexture","coordinates.coordsToOffset"])}if(b===1){const y=`
          float ${h}(int row, int col) {
            int offset_${u} = coordsToOffset(TexCoords, ${b}, ${v});
            float index = dot(vec3(row, col, offset_${u}), vec3(${d[1]}, 1, 1));
            vec2 uv = vec2((index + 0.5) / ${v}.0, 0.5);
            return sampleTexture(${u}, uv);
          }
        `;return new r.GlslLibRoutine(y,["coordinates.sampleTexture","coordinates.coordsToOffset"])}const T=`
        float ${h}(int row, int col) {
          int index = col * ${d[1]} + row;
          vec2 uv = uvFromFlat(${b}, ${v}, index);
          return sampleTexture(${u}, uv);
        }
      `;return new r.GlslLibRoutine(T,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler3D(h,u,i){const d=i.unpackedShape,p=d[1]*d[2],_=d[2],{newShape:m,keptDims:g}=(0,s.squeezeShape)(d),b=m;if(b.length<d.length){const T=(0,l.squeezeInputShape)(d,b),y=["batch","col","row"],w=JSON.parse(JSON.stringify(i));w.unpackedShape=T;const S=this.getUnpackedSamplerFromInput(h,u,w),O=g.reverse(),P=`
          ${S.routineBody}
          float ${h}(int batch, int row, int col) {
            return ${h}(${(0,l.getSqueezedParams)(y,O)});
          }
        `;return new r.GlslLibRoutine(P,S.dependencies)}const v=`
          float ${h}(int depth, int row, int col) {
            // Explicitly use integer operations as dot() only works on floats.
            int index = depth * ${p} + col * ${_} + row;
            vec2 uv = uvFromFlat(${i.width}, ${i.height}, index);
            return sampleTexture(${u}, uv);
          }
      `;return new r.GlslLibRoutine(v,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}getUnpackedSampler4D(h,u,i){const d=i.unpackedShape,p=d[3],_=d[2]*p,m=`
        float ${h}(int row, int col, int depth, int depth2) {
          int index = row * ${d[1]*_} + col * ${_} +
              depth2 * ${p} + depth;
          vec2 uv = uvFromFlat(${i.width}, ${i.height}, index);
          return sampleTexture(${u}, uv);
        }
      `;return new r.GlslLibRoutine(m,["coordinates.uvFromFlat","coordinates.sampleTexture"])}getUnpackedSampler5D(h,u,i){const d=i.unpackedShape,p=d[4],_=d[3]*p,m=d[2]*_,g=d[1]*m,{newShape:b,keptDims:v}=(0,s.squeezeShape)(d);if(b.length<d.length){const y=(0,l.squeezeInputShape)(d,b),w=["row","col","depth","depth2","depth3"],S=JSON.parse(JSON.stringify(i));S.unpackedShape=y;const O=`
          ${this.getUnpackedSamplerFromInput(h,u,S).routineBody}
          float ${h}(int row, int col, int depth, int depth2, int depth3) {
            return ${h}(${(0,l.getSqueezedParams)(w,v)});
          }
        `;return new r.GlslLibRoutine(O,["coordinates.sampleTexture","coordinates.uvFromFlat"])}const T=`
        float ${h}(int row, int col, int depth, int depth2, int depth3) {
          int index = row * ${g} + col * ${m} + depth * ${_} +
          depth3 * ${p} + depth2;
          vec2 uv = uvFromFlat(${i.width}, ${i.height}, index);
          return sampleTexture(${u}, uv);
        }
      `;return new r.GlslLibRoutine(T,["coordinates.sampleTexture","coordinates.uvFromFlat"])}getUnpackedSampler6D(h,u,i){const d=i.unpackedShape,p=d[5],_=d[4]*p,m=d[3]*_,g=d[2]*m,b=d[1]*g,{newShape:v,keptDims:T}=(0,s.squeezeShape)(d);if(v.length<d.length){const w=(0,l.squeezeInputShape)(d,v),S=["row","col","depth","depth2","depth3","depth4"],O=JSON.parse(JSON.stringify(i));O.unpackedShape=w;const P=`
            ${this.getUnpackedSamplerFromInput(h,u,O).routineBody}
            float ${h}(int row, int col, int depth,
              int depth2, int depth3, int depth4) {
              return ${h}(${(0,l.getSqueezedParams)(S,T)});
            }
          `;return new r.GlslLibRoutine(P,["coordinates.sampleTexture","coordinates.uvFromFlat"])}const y=`
          float ${h}(int row, int col, int depth,
            int depth2, int depth3, int depth4) {
            int index = row * ${b} + col * ${g} + depth * ${m} +
            depth2 * ${_} + depth3 * ${p} + depth4;
            vec2 uv = uvFromFlat(${i.width}, ${i.height}, index);
            return sampleTexture(${u}, uv);
          }
        `;return new r.GlslLibRoutine(y,["coordinates.uvFromFlat","coordinates.sampleTexture","coordinates.coordsToOffset"])}toVec(){const h=this.context.outputTextureLayout,u=h.shape.length,i=h.strides,d=h.width,p=h.height,_=[];for(let g=0;g<u-1;++g)_.push(`
        c[${g}] = offset / ${i[g]};`),_.push(`
        offset -= c[${g}] * ${i[g]};`);_.push(`
        c[${u-1}] = offset;`);const m=`
      void toVec(vec2 texCoords, out int c[${u}]) {
        int offset = coordsToOffset(texCoords, ${d}, ${p});
        ${_.join("")}
      }
      void toVec(int offset, out int c[${u}]) {
        ${_.join("")}
      }
    `;return{toVec:new r.GlslLibRoutine(m,["coordinates.coordsToOffset"])}}valueFrom(){const h={};return this.context.programInfo.inputNames.forEach((u,i)=>{const d=this.context.inputTextureLayouts[i],p=(d.unpackedShape.length>0?d.unpackedShape:d.shape).length;let _=`_${u}`;h[_]=new r.GlslLibRoutine(this.getValueFromSingle(u,p,d.width,d.height,!1),[`shapeUtils.indicesToOffset${_}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),_+="_T",h[_]=new r.GlslLibRoutine(this.getValueFromSingle(u,p,d.width,d.height,!0),[`shapeUtils.indicesToOffset${_}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])}),h}getValueFromSingle(h,u,i,d,p){let _=`_${h}`;return p&&(_+="_T"),`
        float ${_}(int m[${u}]) {
          int offset = indicesToOffset${_}(m);
          vec2 coords = offsetToCoords(offset, ${i}, ${d});
          float value = getColorAsFloat(${(0,o.getGlsl)(this.context.glContext.version).texture2D}(${h}, coords));
          return value;
        }
        `}getPackedValueFrom(h,u,i,d,p){let _=`_${h}_Pack`;return p&&(_+="_T"),`
        vec4 ${_}(int m[${u}]) {
          int offset = indicesToOffset_${h}(m);
          vec2 coords = offsetToCoords(offset, ${i}, ${d});
          return ${(0,o.getGlsl)(this.context.glContext.version).texture2D}(${h}, coords);
        }
        `}}e.CoordsGlslLib=c},1997:(a,e)=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.TopologicalSortGlslRoutines=e.GlslLibRoutineNode=e.GlslLibRoutine=e.GlslLib=e.GlslContext=e.FunctionType=void 0,(n=e.FunctionType||(e.FunctionType={}))[n.ValueBased=0]="ValueBased",n[n.Positional=1]="Positional",e.GlslContext=class{constructor(t,r,o,s){this.glContext=t,this.programInfo=r,this.inputTextureLayouts=o,this.outputTextureLayout=s}},e.GlslLib=class{constructor(t){this.context=t}},e.GlslLibRoutine=class{constructor(t,r){this.routineBody=t,this.dependencies=r}},e.GlslLibRoutineNode=class{constructor(t,r,o){this.name=t,this.dependencies=o||[],r&&(this.routineBody=r)}addDependency(t){t&&this.dependencies.push(t)}},e.TopologicalSortGlslRoutines=class{static returnOrderedNodes(t){if(!t||t.length===0)return[];if(t.length===1)return t;const r=new Set,o=new Set,s=new Array;return this.createOrderedNodes(t,r,o,s),s}static createOrderedNodes(t,r,o,s){for(let l=0;l<t.length;++l)this.dfsTraverse(t[l],r,o,s)}static dfsTraverse(t,r,o,s){if(!t||o.has(t.name))return;if(r.has(t.name))throw new Error("Cyclic dependency detected. Can't topologically sort routines needed for shader.");r.add(t.name);const l=t.dependencies;if(l&&l.length>0)for(let c=0;c<l.length;++c)this.dfsTraverse(l[c],r,o,s);s.push(t),o.add(t.name),r.delete(t.name)}}},1371:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EncodingGlslLib=void 0;const t=n(1997);class r extends t.GlslLib{constructor(s){super(s)}getFunctions(){return Object.assign(Object.assign({},this.encodeFloat32()),this.decodeFloat32())}getCustomTypes(){return{}}encodeFloat32(){return{encode:new t.GlslLibRoutine(`highp vec4 encode(highp float f) {
        return vec4(f, 0.0, 0.0, 0.0);
      }
        `)}}decodeFloat32(){return{decode:new t.GlslLibRoutine(`highp float decode(highp vec4 rgba) {
        return rgba.r;
      }
        `)}}encodeUint8(){const s=r.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new t.GlslLibRoutine(`
      highp vec4 encode(highp float f) {
        highp float F = abs(f);
        highp float Sign = step(0.0,-f);
        highp float Exponent = floor(log2(F));
        highp float Mantissa = (exp2(- Exponent) * F);
        Exponent = floor(log2(F) + 127.0) + floor(log2(Mantissa));
        highp vec4 rgba;
        rgba[0] = 128.0 * Sign  + floor(Exponent*exp2(-1.0));
        rgba[1] = 128.0 * mod(Exponent,2.0) + mod(floor(Mantissa*128.0),128.0);
        rgba[2] = floor(mod(floor(Mantissa*exp2(23.0 -8.0)),exp2(8.0)));
        rgba[3] = floor(exp2(23.0)*mod(Mantissa,exp2(-15.0)));
        ${s}
        rgba = rgba / 255.0; // values need to be normalized to [0,1]
        return rgba;
    }
        `)}}decodeUint8(){const s=r.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new t.GlslLibRoutine(`
        highp float decode(highp vec4 rgba) {
          rgba = rgba * 255.0; // values need to be de-normalized from [0,1] to [0,255]
          ${s}
          highp float Sign = 1.0 - step(128.0,rgba[0])*2.0;
          highp float Exponent = 2.0 * mod(rgba[0],128.0) + step(128.0,rgba[1]) - 127.0;
          highp float Mantissa = mod(rgba[1],128.0)*65536.0 + rgba[2]*256.0 +rgba[3] + float(0x800000);
          highp float Result =  Sign * exp2(Exponent) * (Mantissa * exp2(-23.0 ));
          return Result;
      }
        `)}}static isLittleEndian(){const s=new ArrayBuffer(4),l=new Uint32Array(s),c=new Uint8Array(s);if(l[0]=3735928559,c[0]===239)return!0;if(c[0]===222)return!1;throw new Error("unknown endianness")}}e.EncodingGlslLib=r},2691:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.FragColorGlslLib=void 0;const t=n(1997),r=n(6757);class o extends t.GlslLib{constructor(l){super(l)}getFunctions(){return Object.assign(Object.assign({},this.setFragColor()),this.getColorAsFloat())}getCustomTypes(){return{}}setFragColor(){const l=(0,r.getGlsl)(this.context.glContext.version);return{setFragColor:new t.GlslLibRoutine(`
        void setFragColor(float value) {
            ${l.output} = encode(value);
        }
        `,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new t.GlslLibRoutine(`
        float getColorAsFloat(vec4 color) {
            return decode(color);
        }
        `,["encoding.decode"])}}}e.FragColorGlslLib=o},3878:(a,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.replaceInlines=void 0;const n=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm;e.replaceInlines=function(t){const r={};let o;for(;(o=n.exec(t))!==null;){const s=o[3].split(",").map(l=>{const c=l.trim().split(" ");return c&&c.length===2?{type:c[0],name:c[1]}:null}).filter(l=>l!==null);r[o[2]]={params:s,body:o[4]}}for(const s in r){const l="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;".replace("__FUNC__",s),c=new RegExp(l,"gm");for(;(o=c.exec(t))!==null;){const f=o[1],h=o[2],u=o[3].split(","),i=f?`${f} ${h};`:"";let d=r[s].body,p="";r[s].params.forEach((m,g)=>{m&&(p+=`${m.type} ${m.name} = ${u[g]};
`)}),d=`${p}
 ${d}`,d=d.replace("return",`${h} = `);const _=`
      ${i}
      {
        ${d}
      }
      `;t=t.replace(o[0],_)}}return t.replace(n,"")}},8897:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GlslPreprocessor=void 0;const t=n(1997),r=n(3878),o=n(1248),s=n(6757);e.GlslPreprocessor=class{constructor(l,c,f,h){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new t.GlslContext(l,c,f,h),Object.keys(o.glslRegistry).forEach(i=>{const d=new o.glslRegistry[i](this.context);this.libs[i]=d});const u=this.glslLibRoutineDependencyGraph;for(const i in this.libs){const d=this.libs[i].getFunctions();for(const p in d){const _=i+"."+p;let m;u[_]?(m=u[_],m.routineBody=d[p].routineBody):(m=new t.GlslLibRoutineNode(_,d[p].routineBody),u[_]=m);const g=d[p].dependencies;if(g)for(let b=0;b<g.length;++b)if(u[g[b]])m.addDependency(u[g[b]]);else{const v=new t.GlslLibRoutineNode(g[b]);u[g[b]]=v,m.addDependency(v)}}}}preprocess(){const l=this.context.programInfo;let c=l.shaderSource;return this.context.programInfo.hasMain||(c=`${c}
      ${(0,s.getDefaultFragShaderMain)(this.context.glContext.version,this.context.outputTextureLayout.shape.length)}`),c=(0,r.replaceInlines)(c),`${(0,s.getFragShaderPreamble)(this.context.glContext.version)}
    ${this.getUniforms(l.inputNames,l.variables)}
    ${this.getImports(c)}
    ${c}`}getImports(l){const c=this.selectGlslLibRoutinesToBeIncluded(l);if(c.length===0)return"";let f="";for(let h=0;h<c.length;++h){if(!c[h].routineBody)throw new Error(`Missing body for the Glsl Library routine: ${c[h].name}`);f+=c[h].routineBody+`
`}return f}selectGlslLibRoutinesToBeIncluded(l){const c=[];return Object.keys(this.glslLibRoutineDependencyGraph).forEach(f=>{const h=f.split(".")[1];l.indexOf(h)!==-1&&c.push(this.glslLibRoutineDependencyGraph[f])}),t.TopologicalSortGlslRoutines.returnOrderedNodes(c)}getUniforms(l,c){const f=[];if(l)for(const h of l)f.push(`uniform sampler2D ${h};`);if(c)for(const h of c)f.push(`uniform ${h.type} ${h.name}${h.arrayLength?`[${h.arrayLength}]`:""};`);return f.join(`
`)}}},1248:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.glslRegistry=void 0;const t=n(6859),r=n(1371),o=n(2691),s=n(9183),l=n(9314);e.glslRegistry={encoding:r.EncodingGlslLib,fragcolor:o.FragColorGlslLib,vec:l.VecGlslLib,shapeUtils:s.ShapeUtilsGlslLib,coordinates:t.CoordsGlslLib}},9183:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ShapeUtilsGlslLib=void 0;const t=n(1997);class r extends t.GlslLib{constructor(s){super(s)}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.bcastIndex()),this.bcastMatmulIndex()),this.offsetToIndices()),this.indicesToOffset()),this.incrementIndices())}getCustomTypes(){return{}}bcastIndex(){const s=this.context.outputTextureLayout.shape.length,l={};return this.context.programInfo.inputNames.forEach((c,f)=>{const h=this.context.inputTextureLayouts[f].unpackedShape;if(h.length<=s){const u=h.length,i=s-u,d=`bcastIndices_${c}`;let p="";for(let m=0;m<u;++m)p+=`
          realIndices[${m}] = int( mod(float(bcastedIndices[${i+m}]), ${h[m]}.0) );
          `;const _=`
        void ${d} (int bcastedIndices[${s}], out int realIndices[${u}]) {
          ${p}
        }
        `;l[d]=new t.GlslLibRoutine(_)}}),l}bcastMatmulIndex(){const s=this.context.outputTextureLayout.shape.length,l={};return this.context.programInfo.inputNames.forEach((c,f)=>{const h=this.context.inputTextureLayouts[f].shape;if(!(h.length<2||h.length>s)){const u=h.length,i=s-u,d=`bcastMatmulIndices_${c}`;let p="";for(let m=0;m<u-2;++m)p+=`
          realIndices[${m}] = int( mod(float(bcastedIndices[${i+m}]), ${h[m]}.0) );
          `;const _=`
        void ${d}(int bcastedIndices[${s}], out int realIndices[${u}]) {
          ${p}
          realIndices[${u-1}] = bcastedIndices[${s-1}];
          realIndices[${u-2}] = bcastedIndices[${s-2}];
        }
        `;l[d]=new t.GlslLibRoutine(_)}}),l}indicesToOffset(){const s={};return this.context.programInfo.inputNames.forEach((l,c)=>{const f=this.context.inputTextureLayouts[c].shape,h=this.context.inputTextureLayouts[c].strides,u=f.length;let i=`indicesToOffset_${l}`;s[i]=new t.GlslLibRoutine(r.indexToOffsetSingle(i,u,h)),i=`indicesToOffset_${l}_T`,s[i]=new t.GlslLibRoutine(r.indexToOffsetSingle(i,u,h.slice().reverse()))}),s}static indexToOffsetSingle(s,l,c){let f="";for(let h=l-1;h>=0;--h)f+=`
        offset += indices[${h}] * ${c[h]};
        `;return`
      int ${s}(int indices[${l}]) {
        int offset = 0;
        ${f}
        return offset;
      }
      `}offsetToIndices(){const s={};return this.context.programInfo.inputNames.forEach((l,c)=>{const f=this.context.inputTextureLayouts[c].shape,h=this.context.inputTextureLayouts[c].strides,u=f.length;let i=`offsetToIndices_${l}`;s[i]=new t.GlslLibRoutine(r.offsetToIndicesSingle(i,u,h)),i=`offsetToIndices_${l}_T`,s[i]=new t.GlslLibRoutine(r.offsetToIndicesSingle(i,u,h.slice().reverse()))}),s}static offsetToIndicesSingle(s,l,c){const f=[];for(let h=0;h<l-1;++h)f.push(`
      indices[${h}] = offset / ${c[h]};`),f.push(`
        offset -= indices[${h}] * ${c[h]};`);return f.push(`
      indices[${l-1}] = offset;`),`
      void ${s}(int offset, out int indices[${l}]) {
        ${f.join("")}
      }
      `}incrementIndices(){const s={};return this.context.programInfo.inputNames.forEach((l,c)=>{const f=this.context.inputTextureLayouts[c].shape,h=f.length,u=`incrementIndices_${l}`;let i="";for(let p=0;p<h;++p)i+=`
        shape[${p}] = ${f[p]};`;const d=`
        void ${u}(int axis, out int indices[${h}]) {
          int shape[${h}];
          ${i};
          for(int i = ${h} -1 ; i >= 0; --i) {
            if(i > axis) continue;
            indices[i] += 1;
            if(indices[i] < shape[i]) {
              break;
            }
            indices[i] = 0;
          }
        }
        `;s[u]=new t.GlslLibRoutine(d)}),s}}e.ShapeUtilsGlslLib=r},6757:(a,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getDefaultFragShaderMain=e.getFragShaderPreamble=e.getVertexShaderSource=e.getGlsl=void 0;const n={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},t={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"};function r(o){return o===1?n:t}e.getGlsl=r,e.getVertexShaderSource=function(o){const s=r(o);return`${s.version}
      precision highp float;
      ${s.attribute} vec3 position;
      ${s.attribute} vec2 textureCoord;

      ${s.varyingVertex} vec2 TexCoords;

      void main()
      {
          gl_Position = vec4(position, 1.0);
          TexCoords = textureCoord;
      }`},e.getFragShaderPreamble=function(o){const s=r(o);return`${s.version}
    precision highp float;
    precision highp int;
    precision highp sampler2D;
    ${s.varyingFrag} vec2 TexCoords;
    ${s.outputDeclaration}
    const vec2 halfCR = vec2(0.5, 0.5);

    // Custom vector types to handle higher dimenalities.
    struct ivec5
    {
      int x;
      int y;
      int z;
      int w;
      int u;
    };

    struct ivec6
    {
      int x;
      int y;
      int z;
      int w;
      int u;
      int v;
    };

    int imod(int x, int y) {
      return x - y * (x / y);
    }

    `},e.getDefaultFragShaderMain=function(o,s){return`
  void main() {
    int indices[${s}];
    toVec(TexCoords, indices);
    vec4 result = vec4(process(indices));
    ${r(o).output} = result;
  }
  `}},9314:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.VecGlslLib=void 0;const t=n(1997);class r extends t.GlslLib{constructor(s){super(s)}getCustomTypes(){return{}}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign({},this.binaryVecFunctions()),this.copyVec()),this.setVecItem()),this.getVecItem())}binaryVecFunctions(){const s=this.context.outputTextureLayout.shape.length,l={add:"+=",sub:"-=",mul:"*=",div:"/="},c={};for(const f in l){const h=`${f}Vec`;let u="";for(let d=0;d<s;++d)u+=`
          dest[${d}] ${l[f]} src[${d}];
          `;const i=`
        void ${h}(int src[${s}], out int dest[${s}]) {
          ${u}
        }
        `;c[h]=new t.GlslLibRoutine(i)}return c}copyVec(){const s=this.context.outputTextureLayout.shape.length;let l="";for(let f=0;f<s;++f)l+=`
        dest[${f}] = src[${f}];
        `;const c=`
      void copyVec(int src[${s}], out int dest[${s}]) {
        ${l}
      }
      `;return{copyVec:new t.GlslLibRoutine(c)}}setVecItem(){const s=this.context.outputTextureLayout.shape.length;let l=`
        if(index < 0)
            index =${s} + index;
        if (index == 0)
            m[0] = value;
        `;for(let f=1;f<s-1;++f)l+=`
        else if (index == ${f})
            m[${f}] = value;
            `;l+=`
        else
            m[${s-1}] = value;
        `;const c=`
      void setVecItem(out int m[${s}], int index, int value) {
        ${l}
      }
        `;return{setVecItem:new t.GlslLibRoutine(c)}}getVecItem(){const s=this.context.outputTextureLayout.shape.length;let l=`
        if(index < 0)
            index = ${s} + index;
        if (index == 0)
            return m[0];
      `;for(let f=1;f<s-1;++f)l+=`
        else if (index == ${f})
            return m[${f}];
      `;l+=`
        else
            return m[${s-1}];
        `;const c=`
      int getVecItem(int m[${s}], int index) {
        ${l}
      }
    `;return{getVecItem:new t.GlslLibRoutine(c)}}}e.VecGlslLib=r},7860:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLInferenceHandler=void 0;const t=n(1315),r=n(9240),o=n(7273),s=n(9),l=n(7379),c=n(2488),f=n(540),h=n(3314),u=n(5639);e.WebGLInferenceHandler=class{constructor(i){this.session=i,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(i,d){return(0,h.calculateTextureWidthAndHeight)(this.session.layoutStrategy,i,d)}executeProgram(i,d){if(d.length<i.inputNames.length)throw new Error(`Input size mustn't be less than ${i.inputNames.length}.`);if(i.inputNames.length!==i.inputTypes.length)throw new Error("input names size does not match input types");const p=[];for(let T=0;T<i.inputNames.length;++T)p[T]=this.getOrCreateTextureData(d[T],i.inputTypes[T]);const _=((T,y)=>{const w=y.map(O=>`${O.unpackedShape.join(",")};${O.width}x${O.height}`).join("_");let S=T.name;return T.cacheHint&&(S+="["+T.cacheHint+"]"),S+=":"+w,S})(i,p);let m=this.session.programManager.getArtifact(_);const g=m?m.programInfo:typeof i.get=="function"?i.get():i,b=(0,h.createTextureLayoutFromTextureType)(this.session.layoutStrategy,g.output.dims,g.output.textureType),v=this.createTextureData(b,g.output.type);return m||(m=this.session.programManager.build(g,p,v),this.session.programManager.setArtifact(_,m)),this.runProgram(m,p,v),v}run(i,d){return this.executeProgram(i,d).tensor}runProgram(i,d,p){for(let _=0;_<d.length;++_)if(!!d[_].isPacked!=(i.programInfo.inputTypes[_]===u.TextureType.packed))throw new Error(`input[${_}] property packed inconsistent`);if(!!p.isPacked!=(i.programInfo.output.textureType===u.TextureType.packed))throw new Error("output property packed inconsistent");this.session.programManager.run(i,d,p)}getOrCreateTextureData(i,d){let p=this.getTextureData(i.dataId,d===u.TextureType.packed);if(!p&&(p=this.getTextureData(i.dataId,d!==u.TextureType.packed),p))return d===u.TextureType.packed?this.pack(p):this.unpack(p);if(!p){const _=(0,h.createTextureLayoutFromTextureType)(this.session.layoutStrategy,i.dims,d);if(d===u.TextureType.packedLastDimension){const b=i.dims;if(b.length===4){const v=[b[0],Math.ceil(b[1]*b[2]*b[3]/4)],T=(0,h.createTextureLayoutFromTextureType)(this.session.layoutStrategy,v,d);let y=i.numberData;if(b[1]*b[2]*b[3]%4!=0){const w=b[0],S=b[1]*b[2]*b[3],O=Math.ceil(S*1/4)*4;y=new Float32Array(w*O);for(let P=0;P<w;++P){const E=P*S,A=P*O+P%1*S;y.set(i.numberData.subarray(E,E+S),A)}}return this.createTextureData(T,i.type,y,i,1)}}if(d===u.TextureType.packed){const m=(0,h.createTextureLayoutFromShape)(this.session.layoutStrategy,i.dims,1,[],{reverseWH:!0}),g=this.createTextureData(m,i.type,i.numberData,i,1);p=this.pack(g)}else p=this.createTextureData(_,i.type,i.numberData,i,1)}return p}createTextureDataFromLayoutBindTensor(i,d,p,_){return this.createTextureData(i,d,p,_,1)}createTextureData(i,d,p,_,m){t.Logger.verbose("InferenceHandler",`Creating TextureData: layout:[${JSON.stringify(i)}]`);const g=this.session.textureManager.createTextureFromLayout(d,i,p,m);return this.createTextureDataFromTexture(i,d,g,_)}reshapeUnpacked(i,d){const p=this.getOrCreateTextureData(i,u.TextureType.unpacked),_={channels:p.channels,height:p.height,width:p.width,shape:d.length!==0?d:[1],strides:o.ShapeUtil.computeStrides(d),unpackedShape:d};return this.createTextureDataFromTexture(_,i.type,p.texture).tensor}reshapePacked(i,d){const p=this.getOrCreateTextureData(i,u.TextureType.packed);if((0,l.isReshapeCheap)(i.dims,d)){const v={channels:p.channels,height:p.height,width:p.width,shape:d.length!==0?d:[1],strides:o.ShapeUtil.computeStrides(d),unpackedShape:d,isPacked:!0};return this.createTextureDataFromTexture(v,i.type,p.texture).tensor}const _=(0,l.processDims3D)(i.dims),m=(0,l.processDims3D)(d),g=this.reshapePacked(i,_),b=this.run((0,l.createPackedReshape3DProgramInfoLoader)(this,g,m),[g]);return this.reshapePacked(b,d)}cast(i,d){const p=this.getOrCreateTextureData(i,u.TextureType.unpacked);return this.createTextureDataFromTexture(p,d,p.texture).tensor}createTextureDataFromTexture(i,d,p,_,m){const g=Object.assign(Object.assign({},i),{tensor:_||new r.Tensor(i.unpackedShape,d,b=>this.readTexture(g),async b=>this.readTextureAsync(g),void 0,m),texture:p});return this.setTextureData(g.tensor.dataId,g,i.isPacked),g}getTextureData(i,d=!1){return this.session.isInitializer(i)?this.session.getTextureData(i,d):d?this.packedTextureDataCache.get(i):this.unpackedTextureDataCache.get(i)}setTextureData(i,d,p=!1){this.session.isInitializer(i)?this.session.setTextureData(i,d,p):(p?this.packedTextureDataCache:this.unpackedTextureDataCache).set(i,d)}isTextureLayoutCached(i,d=!1){return!!this.getTextureData(i.dataId,d)}dispose(){this.session.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(i=>this.session.textureManager.releaseTexture(i)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(i=>this.session.textureManager.releaseTexture(i)),this.unpackedTextureDataCache=new Map}readTexture(i){return i.isPacked?this.readTexture(this.unpack(i)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTexture(i,i.tensor.type,i.channels):this.session.textureManager.readUint8TextureAsFloat((0,c.encodeAsUint8)(this,i))}async readTextureAsync(i){return i.isPacked?this.readTextureAsync(this.unpack(i)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTextureAsync(i,i.tensor.type,i.channels):this.session.textureManager.readUint8TextureAsFloat((0,c.encodeAsUint8)(this,i))}pack(i){return this.executeProgram((0,s.createPackProgramInfoLoader)(this,i.tensor),[i.tensor])}unpack(i){return this.executeProgram((0,f.createUnpackProgramInfoLoader)(this,i.tensor),[i.tensor])}}},4110:function(a,e,n){var t=this&&this.__createBinding||(Object.create?function(J,Y,te,ee){ee===void 0&&(ee=te);var ie=Object.getOwnPropertyDescriptor(Y,te);ie&&!("get"in ie?!Y.__esModule:ie.writable||ie.configurable)||(ie={enumerable:!0,get:function(){return Y[te]}}),Object.defineProperty(J,ee,ie)}:function(J,Y,te,ee){ee===void 0&&(ee=te),J[ee]=Y[te]}),r=this&&this.__setModuleDefault||(Object.create?function(J,Y){Object.defineProperty(J,"default",{enumerable:!0,value:Y})}:function(J,Y){J.default=Y}),o=this&&this.__importStar||function(J){if(J&&J.__esModule)return J;var Y={};if(J!=null)for(var te in J)te!=="default"&&Object.prototype.hasOwnProperty.call(J,te)&&t(Y,J,te);return r(Y,J),Y};Object.defineProperty(e,"__esModule",{value:!0}),e.WEBGL_OP_RESOLVE_RULES=void 0;const s=n(8817),l=o(n(5194)),c=n(4752),f=n(6668),h=n(9754),u=n(5042),i=n(6742),d=n(4125),p=n(6149),_=n(5378),m=n(6981),g=n(7413),b=n(7006),v=n(8276),T=n(5565),y=n(2834),w=n(1010),S=n(8126),O=n(2801),P=n(565),E=n(2444),A=n(815),$=n(564),k=n(5416),D=n(1240),I=n(5944),C=n(5707),L=o(n(9087)),K=n(7862),G=n(3980);e.WEBGL_OP_RESOLVE_RULES=[["Abs","","6+",L.abs],["Acos","","7+",L.acos],["Add","","7+",l.add],["And","","7+",l.and],["Asin","","7+",L.asin],["Atan","","7+",L.atan],["AveragePool","","7+",y.averagePool,y.parseAveragePoolAttributes],["BatchNormalization","","7+",s.batchNormalization,s.parseBatchNormalizationAttributes],["Cast","","6+",c.cast,c.parseCastAttributes],["Ceil","","6+",L.ceil],["Clip","","6-10",L.clip,L.parseClipAttributes],["Clip","","11+",L.clipV11],["Concat","","4+",f.concat,f.parseConcatAttributes],["Conv","","1+",h.conv,h.parseConvAttributes],["ConvTranspose","","1+",u.convTranspose,u.parseConvTransposeAttributes],["Cos","","7+",L.cos],["Div","","7+",l.div],["Dropout","","7+",L.identity],["DepthToSpace","","1+",i.depthToSpace,i.parseDepthToSpaceAttributes],["Equal","","7+",l.equal],["Elu","","6+",L.elu,L.parseEluAttributes],["Exp","","6+",L.exp],["Flatten","","1+",d.flatten,d.parseFlattenAttributes],["Floor","","6+",L.floor],["FusedConv","com.microsoft","1+",h.conv,h.parseConvAttributes],["Gather","","1+",p.gather,p.parseGatherAttributes],["Gemm","","7-10",_.gemm,_.parseGemmAttributesV7],["Gemm","","11+",_.gemm,_.parseGemmAttributesV11],["GlobalAveragePool","","1+",y.globalAveragePool,y.parseGlobalAveragePoolAttributes],["GlobalMaxPool","","1+",y.globalMaxPool],["Greater","","7+",l.greater],["Identity","","1+",L.identity],["ImageScaler","","1+",m.imageScaler,m.parseImageScalerAttributes],["InstanceNormalization","","6+",g.instanceNormalization,g.parseInstanceNormalizationAttributes],["LeakyRelu","","6+",L.leakyRelu,L.parseLeakyReluAttributes],["Less","","7+",l.less],["LRN","","1+",b.lrn,b.parseLrnAttributes],["Log","","6+",L.log],["MatMul","","1+",v.matMul,v.parseMatMulAttributes],["MaxPool","","1+",y.maxPool,y.parseMaxPoolAttributes],["Mul","","7+",l.mul],["Neg","","6+",L.neg],["Not","","1+",L.not],["Or","","7+",l.or],["Pad","","2-10",T.padV2,T.parsePadAttributesV2],["Pad","","11+",T.padV11,T.parsePadAttributesV11],["Pow","","7+",l.pow],["PRelu","","7+",l.pRelu],["ReduceLogSum","","1+",w.reduceLogSum,w.parseReduceAttributes],["ReduceMax","","1+",w.reduceMax,w.parseReduceAttributes],["ReduceMean","","1+",w.reduceMean,w.parseReduceAttributes],["ReduceMin","","1+",w.reduceMin,w.parseReduceAttributes],["ReduceProd","","1+",w.reduceProd,w.parseReduceAttributes],["ReduceSum","","1-12",w.reduceSum,w.parseReduceAttributes],["ReduceSumSquare","","1+",w.reduceLogSumSquare,w.parseReduceAttributes],["Relu","","6+",L.relu],["Reshape","","5+",S.reshape],["Resize","","10",O.resize,O.parseResizeAttributesV10],["Resize","","11+",O.resize,O.parseResizeAttributesV11],["Shape","","1+",P.shape],["Sigmoid","","6+",L.sigmoid],["Sin","","7+",L.sin],["Slice","","10+",E.sliceV10],["Slice","","1-9",E.slice,E.parseSliceAttributes],["Softmax","","1-12",A.softmax,A.parseSoftmaxAttributes],["Softmax","","13+",A.softmaxV13,A.parseSoftmaxAttributesV13],["Split","","2-12",$.split,$.parseSplitAttributes],["Sqrt","","6+",L.sqrt],["Squeeze","","1-12",k.squeeze,k.parseSqueezeAttributes],["Squeeze","","13+",k.squeezeV13],["Sub","","7+",l.sub],["Sum","","6+",D.sum],["Tan","","7+",L.tan],["Tanh","","6+",L.tanh],["Tile","","6+",I.tile],["Transpose","","1+",C.transpose,C.parseTransposeAttributes],["Upsample","","7-8",G.upsample,G.parseUpsampleAttributesV7],["Upsample","","9",G.upsample,G.parseUpsampleAttributesV9],["Unsqueeze","","1-12",K.unsqueeze,K.parseUnsqueezeAttributes],["Unsqueeze","","13+",K.unsqueezeV13],["Xor","","7+",l.xor]]},8817:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseBatchNormalizationAttributes=e.batchNormalization=void 0;const t=n(4910),r=n(6757),o=n(5639),s={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[o.TextureType.unpacked,o.TextureType.unpacked,o.TextureType.unpacked,o.TextureType.unpacked,o.TextureType.unpacked]};e.batchNormalization=(f,h,u)=>(c(h),[f.run(Object.assign(Object.assign({},s),{cacheHint:u.cacheKey,get:()=>l(f,h,u)}),h)]),e.parseBatchNormalizationAttributes=f=>{const h=f.attributes.getFloat("epsilon",1e-5),u=f.attributes.getFloat("momentum",.9),i=f.attributes.getInt("spatial",1);return(0,t.createAttributeWithCacheKey)({epsilon:h,momentum:u,spatial:i})};const l=(f,h,u)=>{const i=(0,r.getGlsl)(f.session.backend.glContext.version),d=h[0].dims.length,[p,_]=f.calculateTextureWidthAndHeight(h[1].dims,o.TextureType.unpacked),m=`
  float process(int[${d}] indices) {
    vec2 position = offsetToCoords(indices[1], ${p}, ${_});
    float scale = getColorAsFloat(${i.texture2D}(Scale, position));
    float mean = getColorAsFloat(${i.texture2D}(Mean, position));
    float variance = getColorAsFloat(${i.texture2D}(Variance, position));
    float b = getColorAsFloat(${i.texture2D}(B, position));

    return scale * ( (_A(indices) - mean) / sqrt(variance + float(${u.epsilon})) ) + b;
  }`;return Object.assign(Object.assign({},s),{output:{dims:h[0].dims,type:h[0].type,textureType:o.TextureType.unpacked},shaderSource:m})},c=f=>{if(!f||f.length!==5)throw new Error("BatchNormalization requires 5 inputs.");const h=f[0],u=f[1],i=f[2],d=f[3],p=f[4];if(h.dims.length<3||u.dims.length!==1||i.dims.length!==1||d.dims.length!==1||p.dims.length!==1)throw new Error("invalid input shape.");if(u.dims[0]!==h.dims[1]||i.dims[0]!==h.dims[1]||d.dims[0]!==h.dims[1]||p.dims[0]!==h.dims[1])throw new Error("invalid input shape.");if(h.type!=="float32"&&h.type!=="float64"||u.type!=="float32"&&u.type!=="float64"||i.type!=="float32"&&i.type!=="float64"||d.type!=="float32"&&d.type!=="float64"||p.type!=="float32"&&p.type!=="float64")throw new Error("invalid input tensor types.")}},5194:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.xor=e.sub=e.pRelu=e.pow=e.or=e.mul=e.less=e.greater=e.equal=e.div=e.and=e.add=e.glslPRelu=e.glslPow=e.glslXor=e.glslOr=e.glslAnd=e.glslLess=e.glslGreater=e.glslEqual=e.glslSub=e.glslMul=e.glslDiv=e.glslAdd=void 0;const t=n(7273),r=n(1997),o=n(6757),s=n(5639);function l(){const y="add_";return{body:`
  float ${y}(float a, float b) {
    return a + b;
  }
  vec4 ${y}(vec4 v1, vec4 v2) {
    return v1 + v2;
  }
  `,name:y,type:r.FunctionType.ValueBased}}function c(){const y="div_";return{body:`
  float ${y}(float a, float b) {
    return a / b;
  }
  vec4 ${y}(vec4 v1, vec4 v2) {
    return v1 / v2;
  }
  `,name:y,type:r.FunctionType.ValueBased}}function f(){const y="mul_";return{body:`
  float ${y}(float a, float b) {
    return a * b;
  }
  vec4 ${y}(vec4 v1, vec4 v2) {
    return v1 * v2;
  }
  `,name:y,type:r.FunctionType.ValueBased}}function h(){const y="sub_";return{body:`
  float ${y}(float a, float b) {
    return a - b;
  }
  vec4 ${y}(vec4 v1, vec4 v2) {
    return v1 - v2;
  }
  `,name:y,type:r.FunctionType.ValueBased}}function u(){const y="equal_";return{body:`
  float ${y}(float a, float b) {
    return float(a == b);
  }
  vec4 ${y}(vec4 v1, vec4 v2) {
    return vec4(equal(v1, v2));
  }
  `,name:y,type:r.FunctionType.ValueBased}}function i(){const y="greater_";return{body:`
  float ${y}(float a, float b) {
    return float(a > b);
  }
  vec4 ${y}(vec4 v1, vec4 v2) {
    return vec4( v1.r > v2.r ,
      v1.g > v2.g,
      v1.b > v2.b,
      v1.a > v2.a );
  }
  `,name:y,type:r.FunctionType.ValueBased}}function d(){const y="less_";return{body:`
  float ${y}(float a, float b) {
    return float(a < b);
  }
  vec4 ${y}(vec4 v1, vec4 v2) {
    return vec4( v1.r < v2.r ,
                v1.g < v2.g,
                v1.b < v2.b,
                v1.a < v2.a );
  }
  `,name:y,type:r.FunctionType.ValueBased}}function p(){const y="and_";return{body:`
  float ${y}(float a, float b) {
    return float( bool(a) && bool(b) );
  }
  vec4 ${y}(vec4 v1, vec4 v2) {
    bvec4 b1 = bvec4(v1);
    bvec4 b2 = bvec4(v2);
    return vec4( b1.r && b2.r ,
                b1.g && b2.g,
                b1.b && b2.b,
                b1.a && b2.a );
  }
  `,name:y,type:r.FunctionType.ValueBased}}function _(){const y="or_";return{body:`
  float ${y}(float a, float b) {
    return float( bool(a) || bool(b) );
  }
  vec4 ${y}(vec4 v1, vec4 v2) {
    bvec4 b1 = bvec4(v1);
    bvec4 b2 = bvec4(v2);
    return vec4( b1.r || b2.r ,
                b1.g || b2.g,
                b1.b || b2.b,
                b1.a || b2.a );
  }
  `,name:y,type:r.FunctionType.ValueBased}}function m(){const y="xor_";return{body:`
  float ${y}(float a, float b) {
    return float( bool(a) ^^ bool(b) );
  }
  vec4 ${y}(vec4 v1, vec4 v2) {
    bvec4 b1 = bvec4(v1);
    bvec4 b2 = bvec4(v2);
    return vec4( b1.r ^^ b2.r ,
                b1.g ^^ b2.g,
                b1.b ^^ b2.b,
                b1.a ^^ b2.a );
  }
  `,name:y,type:r.FunctionType.ValueBased}}function g(){return function(y){const w=`${y}_`;return{body:`
  float ${w}(float a, float b) {
    return ${y}(a, b);
  }
  vec4 ${w}(vec4 v1, vec4 v2) {
    return ${y}(v1, v2);
  }
  `,name:w,type:r.FunctionType.ValueBased}}("pow")}function b(){const y="prelu_";return{body:`
  float ${y}(float a, float b) {
    return a < 0.0 ? a * b: a;
  }
  vec4 ${y}(vec4 v1, vec4 v2) {
    return vec4(
      v1.r < 0.0 ? v1.r * v2.r: v1.r,
      v1.g < 0.0 ? v1.g * v2.g: v1.g,
      v1.b < 0.0 ? v1.b * v2.b: v1.b,
      v1.a < 0.0 ? v1.a * v2.a: v1.a
      );
  }
  `,name:y,type:r.FunctionType.ValueBased}}e.glslAdd=l,e.glslDiv=c,e.glslMul=f,e.glslSub=h,e.glslEqual=u,e.glslGreater=i,e.glslLess=d,e.glslAnd=p,e.glslOr=_,e.glslXor=m,e.glslPow=g,e.glslPRelu=b;const v=(y,w,S,O=w[0].type,P)=>{const E=y.session.pack?s.TextureType.packed:s.TextureType.unpacked;return{name:S.name,inputNames:["A","B"],inputTypes:[E,E],cacheHint:P,get:()=>T(y,w,S,O)}},T=(y,w,S,O=w[0].type)=>{const P=y.session.pack?s.TextureType.packed:s.TextureType.unpacked,E=!t.ShapeUtil.areEqual(w[0].dims,w[1].dims);let A=w[0].dims;const $=y.session.pack;if(E){const I=t.BroadcastUtil.calcShape(w[0].dims,w[1].dims,!1);if(!I)throw new Error("Can't perform binary op on the given tensors");A=I;const C=A.length,L=w[0].dims.length!==0?w[0].dims.length:1,K=w[1].dims.length!==0?w[1].dims.length:1,G=w[0].dims.length!==0?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",J=w[1].dims.length!==0?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",Y=(0,o.getGlsl)(y.session.backend.glContext.version),te=$?`
      ${S.body}
      void main() {
        vec4 a = getAAtOutCoords();
        vec4 b = getBAtOutCoords();
        vec4 result = ${S.name}(a, b);
        ${Y.output} = result;
      }`:`
      ${S.body}
      float process(int indices[${C}]) {
        int aindices[${L}];
        int bindices[${K}];
        ${G}
        ${J}
        return ${S.name}(_A(aindices), _B(bindices));
      }`;return{name:S.name,inputNames:["A","B"],inputTypes:[P,P],output:{dims:A,type:O,textureType:P},shaderSource:te,hasMain:$}}const k=(0,o.getGlsl)(y.session.backend.glContext.version),D=`
    ${S.body}
    void main() {
      vec4 v1 = ${k.texture2D}(A, TexCoords);
      vec4 v2 = ${k.texture2D}(B, TexCoords);
      vec4 result = ${S.name}(v1, v2);
      ${k.output} = result;
    }
    `;return{name:S.name,inputNames:["A","B"],inputTypes:[P,P],output:{dims:w[0].dims,type:O,textureType:P},shaderSource:D,hasMain:!0}};e.add=(y,w)=>[y.run(v(y,w,l()),w)],e.and=(y,w)=>[y.run(v(y,w,p(),"bool"),w)],e.div=(y,w)=>[y.run(v(y,w,c()),w)],e.equal=(y,w)=>[y.run(v(y,w,u(),"bool"),w)],e.greater=(y,w)=>[y.run(v(y,w,i(),"bool"),w)],e.less=(y,w)=>[y.run(v(y,w,d(),"bool"),w)],e.mul=(y,w)=>[y.run(v(y,w,f()),w)],e.or=(y,w)=>[y.run(v(y,w,_(),"bool"),w)],e.pow=(y,w)=>[y.run(v(y,w,g()),w)],e.pRelu=(y,w)=>[y.run(v(y,w,b()),w)],e.sub=(y,w)=>[y.run(v(y,w,h()),w)],e.xor=(y,w)=>[y.run(v(y,w,m(),"bool"),w)]},4752:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseCastAttributes=e.cast=void 0;const t=n(7273);e.cast=(o,s,l)=>(r(s),[o.cast(s[0],l)]),e.parseCastAttributes=o=>t.ProtoUtil.tensorDataTypeFromProto(o.attributes.getInt("to"));const r=o=>{if(!o||o.length!==1)throw new Error("Cast requires 1 input.");if(o[0].type==="string")throw new Error("Invalid input type.")}},4595:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createPackedConcatProgramInfoLoader=void 0;const t=n(6757),r=n(5639),o=n(432),s=n(5614);e.createPackedConcatProgramInfoLoader=(c,f,h)=>{const u=(i=f.length,d=h.cacheKey,{name:"Concat (packed)",inputNames:Array.from({length:i},(p,_)=>`X${_}`),inputTypes:Array(i).fill(r.TextureType.packed),cacheHint:d});var i,d;return Object.assign(Object.assign({},u),{get:()=>((p,_,m,g)=>{const b=m[0].dims.slice();if(g>=b.length||g<-1*b.length)throw new Error("axis specified for concat doesn't match input dimensionality");g<0&&(g=b.length+g);const v=b.slice(0);for(let G=1;G<m.length;G++){const J=m[G].dims.slice();for(let Y=0;Y<b.length;Y++)if(Y===g)v[g]+=J[Y];else if(b[Y]!==J[Y])throw new Error("non concat dimensions must match")}const T=v.length,y=(0,s.getChannels)("coords",T),w=(0,o.getCoordsDataType)(T),S=(0,s.unpackFromChannel)(),O=m.map(G=>G.dims),P=(0,o.getGlChannels)(T),E=new Array(O.length-1);E[0]=O[0][g];for(let G=1;G<E.length;G++)E[G]=E[G-1]+O[G][g];const A=P[g],$=P.slice(-2),k=P.join();let D=`if (${A} < ${E[0]}) {
        return getChannel(
            getX0(${k}), vec2(${$.join()}));
        }`;for(let G=1;G<E.length;G++){const J=E[G-1];D+=`
            if (${A} < ${E[G]}  && ${A} >= ${E[G-1]}) {
              return getChannel(
                getX${G}(${l(P,A,J)}),
                vec2(${l($,A,J)}));
            }`}const I=E.length,C=E[E.length-1];D+=`
            return getChannel(
              getX${I}(${l(P,A,C)}),
              vec2(${l($,A,C)}));`;const L=(0,t.getGlsl)(p.session.backend.glContext.version),K=`
          ${S}
          float getValue(${P.map(G=>"int "+G)}) {
            ${D}
          }

          void main() {
            ${w} coords = getOutputCoords();
            int lastDim = coords.${P[T-1]};
            coords.${P[T-1]} = coords.${P[T-2]};
            coords.${P[T-2]} = lastDim;

            vec4 result = vec4(getValue(${y}), 0., 0., 0.);

            ${y[T-1]} = ${y[T-1]} + 1;
            if (${y[T-1]} < ${v[T-1]}) {
              result.g = getValue(${y});
            }

            ${y[T-2]} = ${y[T-2]} + 1;
            if (${y[T-2]} < ${v[T-2]}) {
              result.a = getValue(${y});
            }

            ${y[T-1]} = ${y[T-1]} - 1;
            if (${y[T-2]} < ${v[T-2]} &&
                ${y[T-1]} < ${v[T-1]}) {
              result.b = getValue(${y});
            }
            ${L.output} = result;
          }
        `;return Object.assign(Object.assign({},_),{output:{dims:v,type:m[0].type,textureType:r.TextureType.packed},shaderSource:K,hasMain:!0})})(c,u,f,h.axis)})};const l=(c,f,h)=>{const u=c.indexOf(f);return c.map((i,d)=>d===u?`${i} - ${h}`:i).join()}},6668:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseConcatAttributes=e.concat=void 0;const t=n(4910),r=n(5639),o=n(4595);e.concat=(i,d,p)=>(u(d),i.session.pack&&d[0].dims.length>1?[i.run((0,o.createPackedConcatProgramInfoLoader)(i,d,p),d)]:[i.run(s(i,d,p),d)]);const s=(i,d,p)=>{const _=(m=d.length,g=p.cacheKey,{name:"Concat",inputNames:Array.from({length:m},(b,v)=>`X${v}`),inputTypes:Array(m).fill(r.TextureType.unpacked),cacheHint:g});var m,g;return Object.assign(Object.assign({},_),{get:()=>((b,v,T,y)=>{const w=T[0].dims.slice();if(y>=w.length||y<-1*w.length)throw new Error("axis specified for concat doesn't match input dimensionality");y<0&&(y=w.length+y);const S=w.slice(0);for(let k=1;k<T.length;k++){const D=T[k].dims.slice();for(let I=0;I<w.length;I++)if(I===y)S[y]+=D[I];else if(w[I]!==D[I])throw new Error("non concat dimensions must match")}const O=S.length,P=new Array(T.length);let E=0;for(let k=0;k<P.length;++k)E+=T[k].dims[y],P[k]=E;let A="";A=T.length<5?l(P):c(P);const $=`
        ${f(T.length,O)}
        ${h(P)}
        ${A}
        float process(int indices[${O}]) {
          int textureIndex = getTextureWhereDataResides (indices[${y}]);

          if(textureIndex != 0) {
            indices[${y}] = indices[${y}] - int(getSizeInConcatAxisValueFromIndex(textureIndex-int(1)));
          }

          return fetchDataFromCorrectTexture(textureIndex, indices);
        }`;return Object.assign(Object.assign({},v),{output:{dims:S,type:T[0].type,textureType:r.TextureType.unpacked},shaderSource:$})})(0,_,d,p.axis)})},l=i=>`int getTextureWhereDataResides(int index) {
      ${i.map((d,p)=>`if(index<${d}) {return ${p};}
`).join("")}
    }`,c=i=>l(i),f=(i,d)=>{const p=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${d}]) {`];for(let _=0;_<i;++_)_===0?p.push(`	if (textureIndex == ${_}) { return _X${_}(indices); }`):_===i-1?p.push(`	else { return _X${_}(indices); }`):p.push(`	else if (textureIndex == ${_}) { return _X${_}(indices); }`);return p.push("	}"),p.join(`
`)},h=i=>{const d=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let p=0;p<i.length;++p)p===0?d.push(`	if (index == ${p}) { return ${i[p]}; }`):p===i.length-1?d.push(`	else { return ${i[p]}; }`):d.push(`	else if (index == ${p}) { return ${i[p]}; }`);return d.push("	}"),d.join(`
`)};e.parseConcatAttributes=i=>(0,t.createAttributeWithCacheKey)({axis:i.attributes.getInt("axis")});const u=i=>{if(!i||i.length<1)throw new Error("too few inputs");const d=i[0].type,p=i[0].dims.length;if(d==="string")throw new Error("string tensor is not supported yet");for(const _ of i){if(_.type!==d)throw new Error("input tensors should be one type");if(_.dims.length!==p)throw new Error("input tensors should have the same shape")}}},7825:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createUnpackedGroupedConvProgramInfoLoader=void 0;const t=n(1315),r=n(6757),o=n(5639),s=n(9754),l=n(2150);e.createUnpackedGroupedConvProgramInfoLoader=(c,f,h)=>{const u=(i=f.length>2,d=h.cacheKey,{name:"GroupedConv",inputNames:i?["X","W","Bias"]:["X","W"],inputTypes:i?[o.TextureType.unpacked,o.TextureType.unpacked,o.TextureType.unpacked]:[o.TextureType.unpacked,o.TextureType.unpacked],cacheHint:d});var i,d;return Object.assign(Object.assign({},u),{get:()=>((p,_,m,g)=>{const b=_.length>2?"value += getBias(output_channel);":"",v=_[0].dims.slice(),T=_[1].dims.slice(),y=T[0]/g.group;t.Logger.verbose("GroupedConv",`autpPad:${g.autoPad}, dilations:${g.dilations}, group:${g.group}, kernelShape:${g.kernelShape}, pads:${g.pads}, strides:${g.strides}`);const w=(0,s.calculateOutputShape)(v,T,g.dilations,g.pads,g.strides),S=(0,r.getGlsl)(p.session.backend.glContext.version),{activationFunction:O,applyActivation:P}=(0,l.getActivationSnippet)(g),E=`
  const ivec2 strides = ivec2(${g.strides[0]}, ${g.strides[1]});
  const ivec2 pads = ivec2(${g.pads[0]}, ${g.pads[1]});
  ${O}
  void main() {
    ivec4 coords = getOutputCoords();
    int batch = coords.x;
    int output_channel = coords.y;
    ivec2 xRCCorner = coords.zw * strides - pads;
    int group_id = output_channel / ${y};

    float value = 0.0;
    for (int wInChannel = 0; wInChannel < ${T[1]}; wInChannel++) {
      int input_channel = group_id * ${T[1]} + wInChannel;
      for (int wHeight = 0; wHeight < ${T[2]}; wHeight++) {
        int xHeight = xRCCorner.x + wHeight * ${g.dilations[0]};

        if (xHeight < 0 || xHeight >= ${v[2]}) {
          continue;
        }

        for (int wWidth = 0; wWidth < ${T[3]}; wWidth++) {
          int xWidth = xRCCorner.y + wWidth * ${g.dilations[1]};
          if (xWidth < 0 || xWidth >= ${v[3]}) {
            continue;
          }

          float xVal = getX(batch, input_channel, xWidth, xHeight);
          float wVal = getW(output_channel, wInChannel, wWidth, wHeight);
          value += xVal*wVal;
        }
      }
    }
    ${b}
    ${P}
    ${S.output} = vec4(value, .0, .0, .0);
  }
`;return Object.assign(Object.assign({},m),{output:{dims:w,type:_[0].type,textureType:o.TextureType.unpacked},shaderSource:E,hasMain:!0})})(c,f,u,h)})}},7708:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.conv2DPacked=e.conv2DPackedPointwise=void 0;const t=n(9754),r=n(5950),o=n(5632);e.conv2DPackedPointwise=(s,l,c)=>{const f=l[0].dims,h=l[1].dims,u=(0,t.calculateOutputShape)(f,h,c.dilations,c.pads,c.strides),i=s.reshapePacked(l[0],[f[1],f[2]*f[3]]),d=s.reshapePacked(l[1],[h[0],h[1]]),p=l.length>2?[d,i,l[2]]:[d,i],_=s.run((0,o.createPackedMatmulProgramInfoLoader)(s,p,c),p);return s.reshapePacked(_,u)},e.conv2DPacked=(s,l,c)=>{const f=l[0].dims,h=l[1].dims,u=(0,t.calculateOutputShape)(f,h,c.dilations,c.pads,c.strides),i=s.run((0,r.createPackedIm2ColProgramInfoLoader)(s,l[0],l[1],u,c),[l[0]]),d=s.reshapePacked(l[1],[h[0],h[1]*h[2]*h[3]]),p=l.length===3?[d,i,l[2]]:[d,i],_=s.run((0,o.createPackedMatmulProgramInfoLoader)(s,p,c),p);return s.reshapePacked(_,u)}},5042:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseConvTransposeAttributes=e.convTranspose=void 0;const t=n(4910),r=n(6757),o=n(5639),s=n(2150),l=(d,p,_,m,g,b)=>(d-1)*p+_+(m-1)*g+1-b,c=(d,p,_,m,g)=>{const b=Math.floor(d/2);p==="SAME_UPPER"?(_[m]=b,_[g]=d-b):p==="SAME_LOWER"&&(_[m]=d-b,_[g]=b)};e.convTranspose=(d,p,_)=>(i(p,_),f(d,p,_));const f=(d,p,_)=>{const m=u(_,p);return[h(d,p,m)]},h=(d,p,_)=>d.run(((m,g,b)=>{const v=(T=g.length>2,y=b.cacheKey,{name:"ConvTranspose",inputNames:T?["X","W","B"]:["X","W"],inputTypes:T?[o.TextureType.unpacked,o.TextureType.unpacked,o.TextureType.unpacked]:[o.TextureType.unpacked,o.TextureType.unpacked],cacheHint:y});var T,y;return Object.assign(Object.assign({},v),{get:()=>((w,S,O,P)=>{const E=S.length>2?"getB(output_channel)":"0.0",A=S[0].dims,$=S[1].dims,k=$[1],D=$[0]/P.group,I=[S[0].dims[0],S[1].dims[1]*P.group,...P.outputShape],C=(0,r.getGlsl)(w.session.backend.glContext.version),{activationFunction:L,applyActivation:K}=(0,s.getActivationSnippet)(P),G=`
  const ivec2 strides = ivec2(${P.strides[0]}, ${P.strides[1]});
  const ivec2 pads = ivec2(${P.pads[0]}, ${P.pads[1]});
  ${L}
  void main() {
    ivec4 coords = getOutputCoords();
    int batch = coords.x;
    int output_channel = coords.y;

    ivec2 loc = coords.zw + pads;

    int group_id = output_channel / ${k};
    int wOutChannel = output_channel - group_id * ${k};

    float value = ${E};
    for (int inChannelOffset = 0; inChannelOffset < ${D}; inChannelOffset++) {
      int input_channel = group_id * ${D} + inChannelOffset;
      for (int wWOff = 0; wWOff < ${$[2]}; wWOff++) {
        for (int wHOff = 0; wHOff < ${$[3]}; wHOff++) {
          ivec2 wOff = ivec2(wWOff * ${P.dilations[0]}, wHOff * ${P.dilations[1]});
          ivec2 wLoc = loc - wOff;
          ivec2 wLocIn = wLoc / strides;
          if (
            wLocIn * strides == wLoc &&
            wLocIn.x >= 0 && wLocIn.x < ${A[2]} &&
            wLocIn.y >= 0 && wLocIn.y < ${A[3]}
          ) {
            float xVal = getX(batch, input_channel, wLocIn.y, wLocIn.x);
            float wVal = getW(input_channel, wOutChannel, wHOff, wWOff);
            value += xVal * wVal;
          }
        }
      }
    }
    ${K}
    ${C.output} = vec4(value, .0, .0, .0);
  }
`;return Object.assign(Object.assign({},O),{output:{dims:I,type:S[0].type,textureType:o.TextureType.unpacked},shaderSource:G,hasMain:!0})})(m,g,v,b)})})(d,p,_),p),u=(d,p)=>{const _=d.kernelShape.slice();if(d.kernelShape.length===0)for(let v=2;v<p[1].dims.length;++v)_.push(p[1].dims[v]);const m=d.pads.slice(),g=d.outputShape.slice();((v,T,y,w,S,O,P,E)=>{const A=v.length-2,$=E.length===0;for(let k=0;k<A;++k){const D=$?v[k+2]*O[k]:E[k],I=l(v[k+2],O[k],S[k],T[k],y[k],D);c(I,w,S,k,k+A),$&&E.push(O[k]*(v[k+2]-1)+P[k]+(T[k]-1)*y[k]+1-S[k]-S[k+A])}})(p[0].dims,_,d.dilations,d.autoPad,m,d.strides,d.outputPadding,g);const b=Object.assign({},d);return Object.assign(b,{kernelShape:_,pads:m,outputShape:g,cacheKey:d.cacheKey}),b};e.parseConvTransposeAttributes=d=>{const p=d.attributes,_=(0,s.parseInternalActivationAttributes)(p),m=p.getString("auto_pad","NOTSET"),g=p.getInts("dilations",[1,1]),b=p.getInt("group",1),v=p.getInts("kernel_shape",[]),T=p.getInts("output_padding",[0,0]),y=p.getInts("output_shape",[]),w=p.getInts("pads",[0,0,0,0]),S=p.getInts("strides",[1,1]);return(0,t.createAttributeWithCacheKey)(Object.assign({autoPad:m,dilations:g,group:b,kernelShape:v,outputPadding:T,outputShape:y,pads:w,strides:S},_))};const i=(d,p)=>{if(!d||d.length!==2&&d.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(d[0].dims.length!==4||d[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");if(d[0].dims[1]!==d[1].dims[0])throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");const _=d[1].dims[1]*p.group;if(d.length===3&&(d[2].dims.length!==1||d[2].dims[0]!==_))throw new Error("invalid bias");const m=d[0].dims.length-2;if(p.dilations.length!==m)throw new Error(`dilations should be ${m}D`);if(p.strides.length!==m)throw new Error(`strides should be ${m}D`);if(p.pads.length!==2*m)throw new Error(`pads should be ${2*m}D`);if(p.outputPadding.length!==m)throw new Error(`output_padding should be ${m}D`);if(p.kernelShape.length!==0&&p.kernelShape.length!==d[1].dims.length-2)throw new Error("invalid kernel shape");if(p.outputShape.length!==0&&p.outputShape.length!==d[0].dims.length-2)throw new Error("invalid output shape");if(d[0].type!=="float32"||d[1].type!=="float32")throw new Error("ConvTranspose input(X,W) should be float tensor");if(d.length===3&&d[2].type!=="float32")throw new Error("ConvTranspose input(bias) should be float tensor")}},9754:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseConvAttributes=e.conv=e.calculateOutputShape=void 0;const t=n(4910),r=n(7273),o=n(7825),s=n(7708),l=n(3281),c=n(2150),f=n(1625),h=n(8276);e.calculateOutputShape=(m,g,b,v,T)=>{const y=m[0],w=m.slice(2),S=w.length,O=g[0],P=g.slice(2).map((A,$)=>A+(A-1)*(b[$]-1)),E=w.map((A,$)=>A+v[$]+v[$+S]).map((A,$)=>Math.floor((A-P[$]+T[$])/T[$]));return[y,O].concat(...E)},e.conv=(m,g,b)=>(_(g,b),u(m,g,b));const u=(m,g,b)=>{const v=p(b,g),T=m.session.pack,y=v.kernelShape[0]===1&&v.kernelShape[1]===1;return v.group>1?[m.run((0,o.createUnpackedGroupedConvProgramInfoLoader)(m,g,v),g)]:y&&T?[i(m,g,v)]:T&&g[0].dims.length===4&&g[0].dims[0]===1&&!y?[(0,s.conv2DPacked)(m,g,v)]:[d(m,g,v)]},i=(m,g,b)=>{const v=g[0].dims,T=g[1].dims,y=(0,e.calculateOutputShape)(v,T,b.dilations,b.pads,b.strides),w=m.reshapeUnpacked(g[0],[v[1],v[2]*v[3]]),S=m.reshapeUnpacked(g[1],[T[0],T[1]]),O=g.length>2?[S,w,g[2]]:[S,w],P=m.run((0,h.createMatmulProgramInfoLoader)(O,b),O);return m.reshapeUnpacked(P,y)},d=(m,g,b)=>{const v=g[0].dims,T=g[1].dims,y=(0,e.calculateOutputShape)(v,T,b.dilations,b.pads,b.strides),w=m.run((0,f.createIm2ColProgramInfoLoader)(m,g[0],g[1],y,b),[g[0]]),S=g.length===3?[w,g[1],g[2]]:[w,g[1]];return m.run((0,l.createDotProductProgramInfoLoader)(m,g,y,b),S)},p=(m,g)=>{const b=m.kernelShape.slice();if(m.kernelShape.length===0)for(let y=2;y<g[1].dims.length;++y)b.push(g[1].dims[y]);const v=m.pads.slice();r.PoolConvUtil.adjustPadsBasedOnAutoPad(g[0].dims,m.strides,m.dilations,b,v,m.autoPad);const T=Object.assign({},m);return Object.assign(T,{kernelShape:b,pads:v,cacheKey:m.cacheKey}),T};e.parseConvAttributes=m=>{const g=m.attributes,b=(0,c.parseInternalActivationAttributes)(g),v=g.getString("auto_pad","NOTSET"),T=g.getInts("dilations",[1,1]),y=g.getInt("group",1),w=g.getInts("kernel_shape",[]),S=g.getInts("pads",[0,0,0,0]),O=g.getInts("strides",[1,1]);return(0,t.createAttributeWithCacheKey)(Object.assign({autoPad:v,dilations:T,group:y,kernelShape:w,pads:S,strides:O},b))};const _=(m,g)=>{if(!m||m.length!==2&&m.length!==3)throw new Error("Conv requires 2 or 3 inputs");if(m[0].dims.length!==4||m[1].dims.length!==4)throw new Error("currently only support 2-dimensional conv");if(m[0].dims[1]!==m[1].dims[1]*g.group)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(m.length===3&&(m[2].dims.length!==1||m[1].dims[0]!==m[2].dims[0]))throw new Error("invalid bias");const b=m[0].dims.length-2;if(g.dilations.length!==b)throw new Error(`dilations should be ${b}D`);if(g.strides.length!==b)throw new Error(`strides should be ${b}D`);if(g.pads.length!==2*b)throw new Error(`pads should be ${2*b}D`);if(g.kernelShape.length!==0&&g.kernelShape.length!==m[1].dims.length-2)throw new Error("invalid kernel shape");if(m[0].type!=="float32"||m[1].type!=="float32")throw new Error("Conv input(X,W) should be float tensor");if(m.length===3&&m[2].type!=="float32")throw new Error("Conv input(bias) should be float tensor")}},6742:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseDepthToSpaceAttributes=e.depthToSpace=void 0;const t=n(5707);e.depthToSpace=(o,s,l)=>{r(s);const c=l.blocksize,f=c*c,h=l.mode==="DCR"?[0,3,4,1,5,2]:[0,1,4,2,5,3],u=l.mode==="DCR"?[s[0].dims[0],c,c,s[0].dims[1]/f,s[0].dims[2],s[0].dims[3]]:[s[0].dims[0],s[0].dims[1]/f,c,c,s[0].dims[2],s[0].dims[3]],i=o.reshapeUnpacked(s[0],u),d={perm:h,cacheKey:`${h}`},[p]=(0,t.transpose)(o,[i],d),_=[s[0].dims[0],s[0].dims[1]/f,s[0].dims[2]*c,s[0].dims[3]*c];return[o.reshapeUnpacked(p,_)]},e.parseDepthToSpaceAttributes=o=>{const s=o.attributes.getInt("blocksize");if(s<1)throw new Error(`blocksize must be >= 1, but got : ${s} for DepthToSpace`);const l=o.attributes.getString("mode","DCR");if(l!=="DCR"&&l!=="CRD")throw new Error(`unrecognized mode: ${l} for DepthToSpace`);return{mode:l,blocksize:s}};const r=o=>{if(o.length!==1)throw new Error(`DepthToSpace expect 1 inputs, but got ${o.length}`);if(o[0].type==="string"||o[0].dims.length!==4)throw new TypeError("DepthToSpace input should be a 4-D numeric tensor")}},3281:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createDotProductProgramInfoLoader=void 0;const t=n(7273),r=n(6757),o=n(5639),s=n(2150),l=n(1625);e.createDotProductProgramInfoLoader=(c,f,h,u)=>{const i=((d,p)=>({name:"ConvDotProduct",inputNames:d?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:d?[o.TextureType.unpacked,o.TextureType.packedLastDimension,o.TextureType.unpacked]:[o.TextureType.unpacked,o.TextureType.packedLastDimension],cacheKey:p.activationCacheKey}))(f.length>2,u);return Object.assign(Object.assign({},i),{get:()=>((d,p,_,m,g)=>{const b=_[0].dims,v=_[1].dims,T=[v[0],Math.ceil(b[1]*v[2]*v[3]/4)],y=(0,l.calculateIm2ColDims)(b,v,m),[w,S]=d.calculateTextureWidthAndHeight(T,o.TextureType.packedLastDimension),O=t.ShapeUtil.computeStrides(y),[P,E]=d.calculateTextureWidthAndHeight(y,o.TextureType.packedLastDimension),A=m.length,$=_.length<3?"0.0":"_B(b)",k=Math.ceil(b[1]*v[2]*v[3]/4),{activationFunction:D,applyActivation:I}=(0,s.getActivationSnippet)(g),C=(0,r.getGlsl)(d.session.backend.glContext.version),L=`
${D}
float process(int indices[${A}]) {
  int b[1];
  b[0] = indices[1];
  int im2col[4];
  im2col[0] = indices[0];
  im2col[1] = indices[2];
  im2col[2] = indices[3];
  int im2colOffset = im2col[0] * ${O[0]} + im2col[1] * ${O[1]} + im2col[2] * ${O[2]};
  int kernelOffset = indices[1] * ${T[1]};
  float value = ${$};
  for (int i = 0; i < ${k}; ++i) {
    vec2 im2colCoords = offsetToCoords(im2colOffset, ${P}, ${E});
    vec2 kernelCoords = offsetToCoords(kernelOffset, ${w}, ${S});
    value += dot(${C.texture2D}(Im2Col, im2colCoords), ${C.texture2D}(K, kernelCoords));
    ++im2colOffset;
    ++kernelOffset;
  }
  ${I}
  return value;
}`;return Object.assign(Object.assign({},p),{output:{dims:m,type:_[0].type,textureType:o.TextureType.unpacked},shaderSource:L})})(c,i,f,h,u)})}},4125:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseFlattenAttributes=e.flatten=void 0;const t=n(7273);e.flatten=(o,s,l)=>{r(s,l);const c=t.ShapeUtil.flattenShape(s[0].dims,l);return[o.reshapeUnpacked(s[0],c)]},e.parseFlattenAttributes=o=>o.attributes.getInt("axis",1);const r=(o,s)=>{if(!o||o.length!==1)throw new Error("Flatten requires 1 input.");const l=o[0].dims.length;if(l===0)throw new Error("scalar tensor is not supported.");if(s<-l||s>l)throw new Error("Invalid axis");if(o[0].type==="string")throw new Error("string tensor is not supported.")}},2150:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseInternalActivationAttributes=e.getActivationSnippet=void 0;const t=n(7273),r=n(9087);e.getActivationSnippet=function(o){let s;switch(o.activation){case"Relu":s=(0,r.glslRelu)();break;case"Sigmoid":s=(0,r.glslSigmoid)();break;case"Clip":s=(0,r.glslClip)(o.clipMin,o.clipMax);break;default:return{activationFunction:"",applyActivation:""}}const l=s.name;return{activationFunction:s.body,applyActivation:`value = ${l}_(value);`}},e.parseInternalActivationAttributes=o=>{const s=o.getString("activation","");if(s==="Clip"){const[l,c]=o.getFloats("activation_params",[t.MIN_CLIP,t.MAX_CLIP]);return{activation:s,clipMax:c,clipMin:l,activationCacheKey:`${s}:${l},${c}`}}return{activation:s,activationCacheKey:s}}},6149:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseGatherAttributes=e.gather=void 0;const t=n(4910),r=n(6145),o=n(7273),s=n(5639);e.gather=(h,u,i)=>(f(u,i.axis),[h.run(c(h,u,i),u)]),e.parseGatherAttributes=h=>(0,t.createAttributeWithCacheKey)({axis:h.attributes.getInt("axis",0)});const l={name:"Gather",inputNames:["A","B"],inputTypes:[s.TextureType.unpacked,s.TextureType.unpacked]},c=(h,u,i)=>{const d=Object.assign(Object.assign({},l),{cacheHint:i.cacheKey});return Object.assign(Object.assign({},d),{get:()=>((p,_,m,g)=>{const b=m[0].dims.slice(),v=m[1].dims.slice(),T=new Array(b.length+v.length-1);g=o.ShapeUtil.normalizeAxis(g,b.length);const y=[];for(let S=0;S<T.length;S++)S<g?(T[S]=b[S],y.push(`inputIdx[${S}] = outputIdx[${S}];`)):S<g+v.length?(T[S]=v[S-g],y.push(`indexDataIdx[${S-g}] = outputIdx[${S}];`)):(T[S]=b[S-v.length+1],y.push(`inputIdx[${S-v.length+1}] = outputIdx[${S}];`));const w=`
      float process(int outputIdx[${T.length||1}]) {
        int inputIdx[${b.length}];
        int indexDataIdx[${v.length||1}];
        indexDataIdx[0] = 0;
        ${y.join(`
        `)}
        int idx = int(_B(indexDataIdx));
        inputIdx[${g}] = idx < 0 ? idx + ${b[g]} : idx;
        return _A(inputIdx);
      }`;return Object.assign(Object.assign({},_),{output:{dims:T,type:m[0].type,textureType:s.TextureType.unpacked},shaderSource:w})})(0,d,u,i.axis)})},f=(h,u)=>{if(!h||h.length!==2)throw new Error("Gather requires 2 inputs.");const i=h[0].dims.length;if(i<1)throw new Error("Invalid input shape.");if(u<-i||u>i-1)throw new Error("Invalid axis.");if(r.NUMBER_TYPES.indexOf(h[0].type)===-1)throw new Error("Invaid input type.");if(h[1].type!=="int32"&&h[1].type!=="int16")throw new Error("Invaid input type.")}},5378:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseGemmAttributesV11=e.parseGemmAttributesV7=e.gemm=void 0;const t=n(4910),r=n(7273),o=n(5639);e.gemm=(h,u,i)=>(f(u,i),[h.run(l(u,i),u)]);const s=(h,u)=>{const i=h.attributes.getInt("transA",0)!==0,d=h.attributes.getInt("transB",0)!==0,p=h.attributes.getFloat("alpha",1),_=h.attributes.getFloat("beta",1);return(0,t.createAttributeWithCacheKey)({transA:i,transB:d,alpha:p,beta:_,isOptionalC:u})};e.parseGemmAttributesV7=h=>s(h,!1),e.parseGemmAttributesV11=h=>s(h,!0);const l=(h,u)=>{const i={name:"Gemm",inputNames:h.length===3?["A","B","C"]:["A","B"],inputTypes:h.length===3?[o.TextureType.unpacked,o.TextureType.unpacked,o.TextureType.unpacked]:[o.TextureType.unpacked,o.TextureType.unpacked],key:u.cacheKey};return Object.assign(Object.assign({},i),{get:()=>c(i,h,u)})},c=(h,u,i)=>{const d=u[0].dims.slice(),p=u[1].dims.slice(),[_,m]=r.GemmUtil.getShapeOfGemmResult(d,i.transA,p,i.transB,u.length===3?u[2].dims:void 0),g=[_,m];if(!g)throw new Error("Can't use gemm on the given tensors");let b=d[d.length-1],v="";i.transA&&(b=d[0]),i.transA&&i.transB?v="value += _A_T(a) * _B_T(b);":i.transA&&!i.transB?v="value += _A_T(a) * _B(b);":!i.transA&&i.transB?v="value += _A(a) * _B_T(b);":i.transA||i.transB||(v="value += _A(a) * _B(b);");const T=g.length,y=`
      float process(int indices[${T}]) {
          int a[${T}];
          int b[${T}];
          ${u.length===3?`int c[${u[2].dims.length}];`:""}

          copyVec(indices, a);
          copyVec(indices, b);
          ${u.length===3?"bcastIndices_C(indices, c);":""}

          float value = 0.0;
          for (int k=0; k<${b}; ++k) {
              a[${T-1}] = k;
              b[${T-2}] = k;
              ${v}
          }

          value = value * alpha;
          ${u.length===3?"value += beta * _C(c);":""}
          return value;
      }`;return Object.assign(Object.assign({},h),{output:{dims:g,type:u[0].type,textureType:o.TextureType.unpacked},variables:[{name:"alpha",type:"float",data:i.alpha},{name:"beta",type:"float",data:i.beta}],shaderSource:y})},f=(h,u)=>{if(!h)throw new Error("Input is missing");if(u.isOptionalC&&(h.length<2||h.length>3))throw new Error("Invaid input shape.");if(!u.isOptionalC&&h.length!==3)throw new Error("Gemm requires 3 inputs");if(h.length===3&&h[2].dims.length!==1&&h[2].dims.length!==2)throw new Error("Invalid input shape of C");if(h[0].type!=="float32"&&h[0].type!=="float64"||h[1].type!=="float32"&&h[1].type!=="float64"||h.length===3&&h[2].type!=="float32"&&h[2].type!=="float64")throw new Error("Invalid input type.");if(h[0].type!==h[1].type||h.length===3&&h[0].type!==h[2].type)throw new Error("Input types are mismatched")}},5950:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createPackedIm2ColProgramInfoLoader=void 0;const t=n(6757),r=n(5639),o=n(5614);e.createPackedIm2ColProgramInfoLoader=(s,l,c,f,h)=>{const u=(i=h.cacheKey,{name:"Im2Col (packed)",inputNames:["A"],inputTypes:[r.TextureType.packed],cacheHint:i});var i;return Object.assign(Object.assign({},u),{get:()=>((d,p,_,m,g,b)=>{const v=_.dims,T=m.dims,y=g.length,w=[T[1]*T[2]*T[3],g[2]*g[3]],S=T[2]*T[3],O=(0,o.unpackFromChannel)(),P=(0,t.getGlsl)(d.session.backend.glContext.version);let E="";for(let $=0;$<=1;$++)for(let k=0;k<=1;k++)E+=`
            blockIndex = rc.x + ${k};
            pos = rc.y + ${$};

            if(blockIndex < ${w[1]} && pos < ${w[0]}) {
              offsetY = int(blockIndex / (${g[y-1]})) * ${b.strides[0]} -
                ${b.pads[0]};
              d0 = offsetY + ${b.dilations[0]} * (imod(pos, ${S}) / ${T[2]});

              if(d0 < ${v[2]} && d0 >= 0) {
                offsetX = imod(blockIndex, ${g[y-1]}) * ${b.strides[1]} -
                  ${b.pads[1]};
                d1 = offsetX + ${b.dilations[1]} * imod(imod(pos, ${S}), ${T[2]});

                if(d1 < ${v[3]} && d1 >= 0) {

                  ch = int(float(pos)/ ${S}.);
                    innerDims = vec2(d0, d1);
                    result[${2*$+k}] = getChannel(
                      getA(0, ch, int(innerDims.x),
                      int(innerDims.y)), innerDims);
                }
              }
            }

          `;const A=`
      ${O}

      void main() {
        ivec2 rc = getOutputCoords();
          vec4 result = vec4(0.0);
          int blockIndex, pos, offsetY, d0, offsetX, d1, ch;
          vec2 innerDims;
          ${E}
          ${P.output} = result;
      }
            `;return Object.assign(Object.assign({},p),{output:{dims:w,type:_.type,textureType:r.TextureType.packed},shaderSource:A,hasMain:!0})})(s,u,l,c,f,h)})}},1625:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.calculateIm2ColDims=e.createIm2ColProgramInfoLoader=void 0;const t=n(5639);e.createIm2ColProgramInfoLoader=(r,o,s,l,c)=>{const f=(h=c.cacheKey,{name:"Im2Col",inputNames:["X"],inputTypes:[t.TextureType.unpacked],cacheHint:h});var h;return Object.assign(Object.assign({},f),{get:()=>((u,i,d,p,_,m)=>{const g=d.dims,b=p.dims,v=_.length,T=(0,e.calculateIm2ColDims)(g,b,_,4),y=`
        const int XC = ${g[1]};
        const int XH = ${g[2]};
        const int XW = ${g[3]};
        const int KH = ${m.kernelShape[0]};
        const int KW = ${m.kernelShape[1]};
        const int dilationH = ${m.dilations[0]};
        const int dilationW = ${m.dilations[1]};
        const int strideH = ${m.strides[0]};
        const int strideW = ${m.strides[1]};
        const int padH = ${m.pads[0]};
        const int padW = ${m.pads[1]};
        const int KHKW = KH*KW;
        const int XCKHKW = XC * KHKW;
        const int outputChannels = 4;
        vec4 process(int indices[${v}]) {
          int b  = indices[0]; // batch size
          int oh = indices[1] * strideH - padH; //output height
          int ow = indices[2] * strideW - padW; //output width
          int p = indices[3] * outputChannels; //patch
          vec4 value = vec4(0.0);
          for(int i=0; i < outputChannels; ++i) {
            if(p < XCKHKW) {
              int patchC = p / KHKW;
              int patchH = (p - patchC*KHKW) / KW;
              int patchW = (p - patchC*KHKW) - patchH * KW;
              int xh2 = oh + patchH * dilationH;
              int xw2 = ow + patchW * dilationW;
              int x[${g.length}];
              x[0] = b;
              x[1] = patchC;
              x[2] = xh2;
              x[3] = xw2;
              if(xh2 >= 0 &&
                  xh2 < XH &&
                  xw2 >= 0 &&
                  xw2 < XW) {
                value[i] = _X(x);
              }
            }
            ++p;
          }
          return value;
        }
        `;return Object.assign(Object.assign({},i),{output:{dims:T,type:d.type,textureType:t.TextureType.packedLastDimension},shaderSource:y})})(0,f,o,s,l,c)})},e.calculateIm2ColDims=(r,o,s,l=4)=>[s[0],s[2],s[3],Math.ceil(r[1]*o[2]*o[3]/l)]},6981:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseImageScalerAttributes=e.imageScaler=void 0;const t=n(4910),r=n(5639);e.imageScaler=(f,h,u)=>(c(h),[f.run(s(f,h,u),h)]),e.parseImageScalerAttributes=f=>{const h=f.attributes.getFloat("scale"),u=f.attributes.getFloats("bias");return(0,t.createAttributeWithCacheKey)({scale:h,bias:u})};const o={name:"ImageScaler",inputNames:["X"],inputTypes:[r.TextureType.unpacked]},s=(f,h,u)=>{const i=Object.assign(Object.assign({},o),{cacheHint:u.cacheKey});return Object.assign(Object.assign({},i),{get:()=>((d,p,_,m)=>{const g=_[0].dims.slice(),b=g.length,v=`
      ${l(m.bias.length)}
      float process(int indices[${b}]) {
        return _X(indices) * scale + getBias(bias, indices[1]);
      }`;return Object.assign(Object.assign({},p),{output:{dims:g,type:_[0].type,textureType:r.TextureType.unpacked},variables:[{name:"bias",type:"float",arrayLength:m.bias.length,data:m.bias},{name:"scale",type:"float",data:m.scale}],shaderSource:v})})(0,i,h,u)})},l=f=>{const h=[`float getBias(float bias[${f}], int channel) {`];for(let u=0;u<f;++u)u===0?h.push(`	if (channel == ${u}) { return bias[${u}]; }`):u===f-1?h.push(`	else { return bias[${u}]; }`):h.push(`	else if (channel == ${u}) { return bias[${u}]; }`);return h.push("	}"),h.join(`
`)},c=f=>{if(!f||f.length!==1)throw new Error("ImageScaler requires 1 input.");if(f[0].dims.length!==4)throw new Error("Invalid input shape.");if(f[0].type!=="float32"&&f[0].type!=="float64")throw new Error("Invalid input type.")}},7413:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseInstanceNormalizationAttributes=e.instanceNormalization=void 0;const t=n(6757),r=n(5639);e.instanceNormalization=(h,u,i)=>{f(u);const d=h.run(s(u[0]),u);return[h.run(c(h,u[0],i,d.dims),[u[0],d,u[1],u[2]])]},e.parseInstanceNormalizationAttributes=h=>h.attributes.getFloat("epsilon",1e-5);const o={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[r.TextureType.unpacked]},s=h=>Object.assign(Object.assign({},o),{get:()=>((u,i)=>{const d=i.dims.slice(),p=d[1],_=d[2]*d[3],m=[d[0],p],g=`
      vec4 process(int[2] indices) {
        vec4 v = vec4(0.0);
        int a[4];
        a[0] = indices[0];
        a[1] = indices[1];
        float temp = 0.0;
        for(int a2=0; a2<${d[2]}; a2++) {
          a[2] = a2;
          for(int a3=0; a3<${d[3]}; a3++) {
            a[3] = a3;
            float x = _X(a);
            temp += x;
          }
        }
        float mean = temp / float(${_});
        temp = 0.0;
        for(int a2=0; a2<${d[2]}; a2++) {
          a[2] = a2;
          for(int a3=0; a3<${d[3]}; a3++) {
            a[3] = a3;
            float x = _X(a);
            temp += (x - mean) * (x - mean);
          }
        }
        v.r = mean;
        v.g = temp / float(${_});

        return v;
      }`;return Object.assign(Object.assign({},u),{output:{dims:m,type:i.type,textureType:r.TextureType.packedLastDimension},shaderSource:g})})(o,h)}),l={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[r.TextureType.unpacked,r.TextureType.packedLastDimension,r.TextureType.unpacked,r.TextureType.unpacked]},c=(h,u,i,d)=>{const p=Object.assign(Object.assign({},l),{cacheHint:`${i}`});return Object.assign(Object.assign({},p),{get:()=>((_,m,g,b,v)=>{const T=(0,t.getGlsl)(_.session.backend.glContext.version),[y,w]=_.calculateTextureWidthAndHeight(v,r.TextureType.packedLastDimension),[S,O]=[y/4,w],P=`
      vec4 get_MeanAndVariance(int[2] mv) {
        int offset = indicesToOffset_MeanAndVariance(mv);
        vec2 coords = offsetToCoords(offset, ${S}, ${O});
        return ${T.texture2D}(MeanAndVariance, coords);
      }

      float process(int[4] indices) {
        int mv[2];
        mv[0] = indices[0];
        mv[1] = indices[1];
        vec4 mean_and_variance = get_MeanAndVariance(mv);
        float mean = mean_and_variance.r;
        float variance = mean_and_variance.g;

        int sb[1];
        sb[0] = indices[1];
        float scale = _Scale(sb);
        float b = _B(sb);

        return scale * (_X(indices) - mean) / sqrt(variance + epsilon) + b;
      }`;return Object.assign(Object.assign({},m),{output:{dims:g.dims,type:g.type,textureType:r.TextureType.unpacked},variables:[{name:"epsilon",type:"float",data:b}],shaderSource:P})})(h,p,u,i,d)})},f=h=>{if(!h||h.length!==3)throw new Error("InstanceNormalization requires 3 inputs.");const u=h[0],i=h[1],d=h[2];if(u.dims.length<3||i.dims.length!==1||d.dims.length!==1)throw new Error("Invalid input shape.");if(i.dims[0]!==u.dims[1]||d.dims[0]!==u.dims[1])throw new Error("Input shapes are mismatched.");if(u.type!=="float32"&&u.type!=="float64"||i.type!=="float32"&&i.type!=="float64"||d.type!=="float32"&&d.type!=="float64")throw new Error("Invalid input type.");if(h[0].dims.length!==4)throw new Error("Only support 4-D input shape.")}},7006:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createLrnProgramInfoLoader=e.parseLrnAttributes=e.lrn=void 0;const t=n(4910),r=n(5639);e.lrn=(c,f,h)=>(l(f),[c.run(s(f,h),f)]),e.parseLrnAttributes=c=>{const f=c.attributes.getFloat("alpha",1e-4),h=c.attributes.getFloat("beta",.75),u=c.attributes.getFloat("bias",1),i=c.attributes.getInt("size");return(0,t.createAttributeWithCacheKey)({alpha:f,beta:h,bias:u,size:i})};const o={name:"LRN",inputNames:["X"],inputTypes:[r.TextureType.unpacked]};function s(c,f){return Object.assign(Object.assign({},o),{cacheHint:f.cacheKey,get:()=>function(h,u){const i=h[0].dims[1],d=h[0].dims.length,p=-Math.floor((u.size-1)/2),_=Math.ceil((u.size-1)/2),m=`float(${u.alpha}) / float(${u.size})`,g=`
    float process(int indices[${d}]) {
        int c = indices[1];
        float x = _X(indices);
        float square_sum = 0.0;

        for (int i = ${p}; i <= ${_}; i++) {
          int idx = c + i;
          if (c >= 0 && c < ${i}) {
            indices[1] = idx;
            float j = _X(indices);
            square_sum += j * j;
          }
        }
        return x / pow(float(${u.bias}) + ${m} * square_sum, float(${u.beta}));
    }`;return Object.assign(Object.assign({},o),{cacheHint:u.cacheKey,output:{dims:h[0].dims,type:h[0].type,textureType:r.TextureType.unpacked},shaderSource:g})}(c,f)})}e.createLrnProgramInfoLoader=s;const l=c=>{if(!c||c.length!==1)throw new Error("LRN requires 1 input.");if(c[0].dims.length!==4)throw new Error('currently only support LRN for input with "NCHW" format');if(c[0].type!=="float32")throw new Error("input should be float type")}},5632:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createPackedMatmulProgramInfoLoader=void 0;const t=n(7273),r=n(6757),o=n(5639),s=n(432),l=n(2150),c=n(8276);e.createPackedMatmulProgramInfoLoader=(f,h,u)=>{const i=(d=h.length>2,p=u.activationCacheKey,{name:"MatMul (packed)",inputNames:d?["A","B","Bias"]:["A","B"],inputTypes:d?[o.TextureType.packed,o.TextureType.packed,o.TextureType.packed]:[o.TextureType.packed,o.TextureType.packed],cacheHint:p});var d,p;return Object.assign(Object.assign({},i),{get:()=>((_,m,g,b)=>{const v=g.length>2,T=v?"value += getBiasForMatmul();":"",y=g[0].dims,w=g[1].dims,S=t.BroadcastUtil.calcShape(y,w,!0),O=!t.ShapeUtil.areEqual(g[0].dims,g[1].dims);if(!S)throw new Error("Can't use matmul on the given tensors");const P=y[y.length-1],E=Math.ceil(P/2),A=y.length,$=w.length,k=(0,r.getGlsl)(_.session.backend.glContext.version),D=(0,s.getCoordsDataType)(S.length),I=S.length,C=(0,s.getGlChannels)(),{activationFunction:L,applyActivation:K}=(0,l.getActivationSnippet)(b),G=v?`${(0,c.getBiasForMatmul)(D,C,g[2].dims,S,!0)}`:"",J=O?`${function(ie,ae,ue,fe){let ge=[],be=[];const xe=ue[0].dims,ve=ue[1].dims,Te=xe.length,pe=ve.length,ke=fe.length,Pe=ke-Te,Ie=ke-pe;ge=xe.map((Oe,Fe)=>`coords.${ae[Fe+Pe]}`),ge[Te-1]="i*2",ge.join(", "),be=ve.map((Oe,Fe)=>`coords.${ae[Fe+Ie]}`),be[pe-2]="i*2",be.join(", ");const Ce=t.BroadcastUtil.getBroadcastDims(xe,fe),Ne=t.BroadcastUtil.getBroadcastDims(ve,fe),Ae=Ce.map(Oe=>`coords.${ae[Oe+Pe]} = 0;`).join(`
`),Ve=Ne.map(Oe=>`coords.${ae[Oe+Ie]} = 0;`).join(`
`),$e=`int lastDim = coords.${ae[ke-1]};
  coords.${ae[ke-1]} = coords.${ae[ke-2]};
  coords.${ae[ke-2]} = lastDim;`;return`
vec4 getAAtOutCoordsMatmul(int i) {
  ${ie} coords = getOutputCoords();
  ${$e}
  ${Ae}
  vec4 outputValue = getA(${ge});
  return outputValue;
}

vec4 getBAtOutCoordsMatmul(int i) {
  ${ie} coords = getOutputCoords();
  ${$e}
  ${Ve}
  vec4 outputValue = getB(${be});
  return outputValue;
}`}(D,C,g,S)}`:"",Y=O?"getAAtOutCoordsMatmul(i)":`getA(${function(ie,ae){let ue="";for(let fe=0;fe<ae-2;fe++)ue+=`rc.${ie[fe]}, `;return ue+=`rc.${ie[ae-2]}, i*2`,ue}(C,A)})`,te=O?"getBAtOutCoordsMatmul(i)":`getB(${function(ie,ae){let ue="";for(let fe=0;fe<ae-2;fe++)ue+=`rc.${ie[fe]}, `;return ue+=`i*2, rc.${ie[ae-1]}`,ue}(C,$)})`,ee=`
            ${J}
            ${G}
            ${L}
            void main() {
              ${O?"":`${D} rc =
          getOutputCoords(); int lastDim = rc.${C[I-1]}; rc.${C[I-1]} =
          rc.${C[I-2]}; rc.${C[I-2]} = lastDim;
      `}

              vec4 value = vec4(0);
              for (int i = 0; i < ${E}; i++) {
                vec4 a = ${Y};
                vec4 b = ${te};

                value += (a.rrbb * b.rgrg);
                value += (a.ggaa * b.baba);
              }
              ${T}
              ${K}
              ${k.output} = value;
            }`;return Object.assign(Object.assign({},m),{output:{dims:S,type:g[0].type,textureType:o.TextureType.packed},shaderSource:ee,hasMain:!0})})(f,i,h,u)})}},8276:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getBiasForMatmul=e.createMatmulProgramInfoLoader=e.parseMatMulAttributes=e.matMul=void 0;const t=n(7273),r=n(5639),o=n(432),s=n(2150),l=n(5632);e.matMul=(i,d,p)=>(h(d),i.session.pack?[i.run((0,l.createPackedMatmulProgramInfoLoader)(i,d,p),d)]:[i.run(f(d,p),d)]),e.parseMatMulAttributes=i=>(0,s.parseInternalActivationAttributes)(i.attributes);const c=(i,d)=>({name:"MatMul",inputNames:i?["A","B","Bias"]:["A","B"],inputTypes:i?[r.TextureType.unpacked,r.TextureType.unpacked,r.TextureType.unpacked]:[r.TextureType.unpacked,r.TextureType.unpacked],cacheHint:d});function f(i,d){const p=c(i.length>2,d.activationCacheKey);return Object.assign(Object.assign({},p),{get:()=>function(_,m,g){const b=m[0].dims,v=m[1].dims,T=t.BroadcastUtil.calcShape(b,v,!0);if(!T)throw new Error("Can't use matmul on the given tensors");const y=(0,o.getCoordsDataType)(T.length),w=(0,o.getGlChannels)(),{activationFunction:S,applyActivation:O}=(0,s.getActivationSnippet)(g),P=m.length>2,E=P?"value += getBiasForMatmul();":"",A=P?`${u(y,w,m[2].dims,T,!1)}`:"",$=T.length,k=b.length,D=v.length,I=`
    ${S}
    ${A}
    float process(int indices[${$}]) {
        int a[${k}];
        int b[${D}];
        bcastMatmulIndices_A(indices, a);
        bcastMatmulIndices_B(indices, b);

        float value;
        for (int k=0; k<${b[b.length-1]}; ++k) {
            a[${k-1}] = k;
            b[${D-2}] = k;
            value += _A(a) * _B(b);
        }
        ${E}
        ${O}
        return value;
    }`;return Object.assign(Object.assign({},_),{output:{dims:T,type:m[0].type,textureType:r.TextureType.unpacked},shaderSource:I})}(p,i,d)})}e.createMatmulProgramInfoLoader=f;const h=i=>{if(!i||i.length!==2)throw new Error("MatMul requires 2 inputs.");if(i[0].dims[i[0].dims.length-1]!==i[1].dims[i[1].dims.length-2])throw new Error("shared dimension does not match.");if(i[0].type!=="float32"&&i[0].type!=="float64"||i[1].type!=="float32"&&i[1].type!=="float64")throw new Error("inputs should be float type");if(i[0].type!==i[1].type)throw new Error("inputs types should match")};function u(i,d,p,_,m){let g="";const b=p.length,v=_.length,T=v-b;g=v<2&&b>0?"coords":p.map((S,O)=>`coords.${d[O+T]}`).join(", ");const y=t.BroadcastUtil.getBroadcastDims(p,_).map(S=>`coords.${d[S+T]} = 0;`).join(`
`);let w="vec4(outputValue.xx, outputValue.yy)";return t.ShapeUtil.size(p)===1&&(w="vec4(outputValue.x)"),m?`
vec4 getBiasForMatmul() {
  ${i} coords = getOutputCoords();
  ${y}
  vec4 outputValue = getBias(${g});
  return ${w};
}`:`
float getBiasForMatmul() {
  ${i} coords = getOutputCoords();
  ${y}
  return getBias(coords.x);
}`}e.getBiasForMatmul=u},9:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createPackProgramInfoLoader=void 0;const t=n(6757),r=n(5639),o=n(432),s=n(5614),l={name:"pack",inputNames:["A"],inputTypes:[r.TextureType.unpackedReversed]};e.createPackProgramInfoLoader=(c,f)=>Object.assign(Object.assign({},l),{get:()=>((h,u)=>{const i=(0,t.getGlsl)(h.session.backend.glContext.version),d=u.dims,p=d.length,_=u.dims.length,m=(0,o.getCoordsDataType)(_),g=(0,s.getChannels)("rc",_),b=(v=_,T=g,y=d[d.length-2],w=d[d.length-1],v===0||v===1?"":`
    int r = ${T[v-2]};
    int c = ${T[v-1]};
    int rp1 = ${T[v-2]} + 1;
    int cp1 = ${T[v-1]} + 1;
    bool rEdge = rp1 >= ${w};
    bool cEdge = cp1 >= ${y};
    `);var v,T,y,w;let S;S=p===0?[1,1]:p===1?[d[0],1]:[d[_-1],d[_-2]];const O=function(A,$,k){if(A===0)return"false";if(A===1)return`rc > ${$[0]}`;let D="";for(let I=A-2;I<A;I++)D+=`${k[I]} >= ${$[I-A+2]}`,I<A-1&&(D+="||");return D}(_,S,g),P=function(A,$){const k=A.length;if(k===0)return"getA(), 0, 0, 0";if(k===1)return`getA(rc),
            rc + 1 >= ${A[0]} ? 0. : getA(rc + 1),
            0, 0`;let D="";if(k>2)for(let I=0;I<k-2;++I)D+=`${$[I]},`;return`getA(${D}r, c),
          rEdge ? 0. : getA(${D}rp1, c),
          cEdge ? 0. : getA(${D}r, cp1),
          rEdge || cEdge ? 0. : getA(${D}rp1, cp1)`}(d,g),E=`
        void main() {
          ${m} rc = getOutputCoords();

          if(${O}) {
            ${i.output} = vec4(0);
          } else {
            ${b}

            ${i.output} = vec4(${P});
          }
        }
      `;return Object.assign(Object.assign({},l),{hasMain:!0,output:{dims:u.dims,type:u.type,textureType:r.TextureType.packed},shaderSource:E})})(c,f)})},5614:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.unpackFromChannel=e.getChannels=e.getVecChannels=void 0;const t=n(432);function r(o,s){return(0,t.getGlChannels)(s).map(l=>`${o}.${l}`)}e.getVecChannels=r,e.getChannels=function(o,s){return s===1?[o]:r(o,s)},e.unpackFromChannel=function(){return`
    float getChannel(vec4 frag, int dim) {
      int modCoord = imod(dim, 2);
      return modCoord == 0 ? frag.r : frag.g;
    }

    float getChannel(vec4 frag, vec2 innerDims) {
      vec2 modCoord = mod(innerDims, 2.);
      return modCoord.x == 0. ?
        (modCoord.y == 0. ? frag.r : frag.g) :
        (modCoord.y == 0. ? frag.b : frag.a);
    }
  `}},5565:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parsePadAttributesV11=e.padV11=e.parsePadAttributesV2=e.padV2=void 0;const t=n(4910),r=n(7273),o=n(6757),s=n(5639),l={name:"Pad",inputNames:["A"],inputTypes:[s.TextureType.unpacked]};e.padV2=(m,g,b)=>(h(g),[m.run(Object.assign(Object.assign({},l),{cacheHint:b.cacheKey,get:()=>f(m,g[0],b)}),g)]),e.parsePadAttributesV2=m=>{const g=m.attributes.getString("mode","constant"),b=m.attributes.getFloat("value",0),v=m.attributes.getInts("pads");return(0,t.createAttributeWithCacheKey)({mode:g,value:b,pads:v})},e.padV11=(m,g,b)=>{u(g);const v=c(m,g,b);return(0,e.padV2)(m,[g[0]],v)},e.parsePadAttributesV11=m=>m.attributes.getString("mode","constant");const c=(m,g,b)=>{if(!m.session.isInitializer(g[1].dataId)||g.length>=3&&!m.session.isInitializer(g[2].dataId))throw new Error("dynamic pad attributes are not allowed");const v=Array.from(g[1].integerData),T=g.length>=3?g[2].floatData[0]:0;return(0,t.createAttributeWithCacheKey)({mode:b,pads:v,value:T})},f=(m,g,b)=>{const v=r.ShapeUtil.padShape(g.dims.slice(),b.pads),T=v.length,y=`
      ${i(m,g,b)}
      float process(int[${T}] indices) {
          return padA(indices);
      }`;return{name:"Pad",inputNames:["A"],inputTypes:[s.TextureType.unpacked],output:{dims:v,type:g.type,textureType:s.TextureType.unpacked},shaderSource:y}},h=m=>{if(!m||m.length!==1)throw new Error("Pad requires 1 input");if(m[0].type!=="float32"&&m[0].type!=="float64")throw new Error("Invalid input type.")},u=m=>{if(!m||m.length!==2&&m.length!==3)throw new Error("Pad requires 2 or 3 inputs");if(m[1].type!=="int32")throw new Error("Invalid input type.");if(m.length>=3&&m[2].type==="string")throw new Error("Invalid input type.")},i=(m,g,b)=>{const v=(0,o.getGlsl)(m.session.backend.glContext.version),[T,y]=m.calculateTextureWidthAndHeight(g.dims,s.TextureType.unpacked),w=r.ShapeUtil.computeStrides(g.dims);switch(b.mode){case"constant":return d(v,g.dims,w,T,y,b.pads,b.value);case"reflect":return p(v,g.dims,w,T,y,b.pads);case"edge":return _(v,g.dims,w,T,y,b.pads);default:throw new Error("Invalid mode")}},d=(m,g,b,v,T,y,w)=>{const S=g.length;let O="";for(let P=S-1;P>=0;--P)O+=`
        k = m[${P}] - ${y[P]};
        if (k < 0)  return constant;
        if (k >= ${g[P]}) return constant;
        offset += k * ${b[P]};
        `;return`
      float padA(int m[${S}]) {
        const float constant = float(${w});
        int offset = 0;
        int k = 0;
        ${O}
        vec2 coords = offsetToCoords(offset, ${v}, ${T});
        float value = getColorAsFloat(${m.texture2D}(A, coords));
        return value;
      }
      `},p=(m,g,b,v,T,y)=>{const w=g.length;let S="";for(let O=w-1;O>=0;--O)S+=`
        k = m[${O}] - ${y[O]};
        if (k < 0) { k = -k; }
        {
          const int _2n_1 = ${2*(g[O]-1)};
          k = int( mod( float(k), float(_2n_1) ) ) ;
          if(k >= ${g[O]}) { k = _2n_1 - k; }
        }
        offset += k * ${b[O]};
        `;return`
      float padA(int m[${w}]) {
        int offset = 0;
        int k = 0;
        ${S}
        vec2 coords = offsetToCoords(offset, ${v}, ${T});
        float value = getColorAsFloat(${m.texture2D}(A, coords));
        return value;
      }
      `},_=(m,g,b,v,T,y)=>{const w=g.length;let S="";for(let O=w-1;O>=0;--O)S+=`
        k = m[${O}] - ${y[O]};
        if (k < 0)  k = 0;
        if (k >= ${g[O]}) k = ${g[O]-1};
        offset += k * ${b[O]};
      `;return`
      float padA(int m[${w}]) {
        int offset = 0;
        int k = 0;
        ${S}
        vec2 coords = offsetToCoords(offset, ${v}, ${T});
        float value = getColorAsFloat(${m.texture2D}(A, coords));
        return value;
      }
      `}},2834:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.globalMaxPool=e.parseMaxPoolAttributes=e.maxPool=e.parseGlobalAveragePoolAttributes=e.globalAveragePool=e.parseAveragePoolAttributes=e.averagePool=void 0;const t=n(4910),r=n(7273),o=n(5639);e.averagePool=(_,m,g)=>{u(m);const b={name:"AveragePool",inputNames:["X"],inputTypes:[o.TextureType.unpacked],cacheHint:g.cacheKey};return[_.run(Object.assign(Object.assign({},b),{get:()=>s(m,b,!1,g)}),m)]},e.parseAveragePoolAttributes=_=>{const m=_.attributes.getString("auto_pad","NOTSET"),g=_.attributes.getInt("ceil_mode",0),b=_.attributes.getInt("count_include_pad",0)!==0,v=_.attributes.getInts("kernel_shape"),T=_.attributes.getInts("strides",[]),y=_.attributes.getInts("pads",[]);if(g!==0)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return(0,t.createAttributeWithCacheKey)({autoPad:m,ceilMode:g,countIncludePad:b,kernelShape:v,strides:T,pads:y})};const s=(_,m,g,b)=>{const[v,T]=c(_,b,g),y=r.ShapeUtil.size(v.kernelShape);let w="";v.countIncludePad?w+=`value /= float(${y});`:w+=`value /= float(${y} - pad);`;const S=`
        ${i(_[0].dims,v,"value += _X(x);",w,"0.0")}
      `;return Object.assign(Object.assign({},m),{output:{dims:T,type:_[0].type,textureType:o.TextureType.unpacked},shaderSource:S})};e.globalAveragePool=(_,m,g)=>{u(m);const b={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[o.TextureType.unpacked],cacheHint:`${g.countIncludePad}`};return[_.run(Object.assign(Object.assign({},b),{get:()=>s(m,b,!0,g)}),m)]},e.parseGlobalAveragePoolAttributes=_=>{const m=_.attributes.getInt("count_include_pad",0)!==0;return(0,t.createAttributeWithCacheKey)({autoPad:"",ceilMode:0,countIncludePad:m,kernelShape:[],strides:[],pads:[]})},e.maxPool=(_,m,g)=>{u(m);const b={name:"MaxPool",inputNames:["X"],inputTypes:[o.TextureType.unpacked],cacheHint:g.cacheKey};return[_.run(Object.assign(Object.assign({},b),{get:()=>l(m,b,!1,g)}),m)]},e.parseMaxPoolAttributes=_=>{const m=_.attributes.getString("auto_pad","NOTSET"),g=_.attributes.getInt("ceil_mode",0),b=_.attributes.getInts("kernel_shape"),v=_.attributes.getInts("strides",[]),T=_.attributes.getInts("pads",[]),y=_.attributes.getInt("storage_order",0),w=_.attributes.getInts("dilations",[]);if(y!==0)throw new Error("column major storage order is not yet supported for MaxPool");if(g!==0)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return(0,t.createAttributeWithCacheKey)({autoPad:m,ceilMode:g,countIncludePad:!1,kernelShape:b,strides:v,pads:T,storageOrder:y,dilations:w})};const l=(_,m,g,b)=>{const[v,T]=c(_,b,g),y=`
      ${i(_[0].dims,v,`
      value = max(_X(x), value);
    `,"","-1e5")}
    `;return Object.assign(Object.assign({},m),{output:{dims:T,type:_[0].type,textureType:o.TextureType.unpacked},shaderSource:y})},c=(_,m,g)=>{const b=_[0].dims.slice(),v=Object.hasOwnProperty.call(m,"dilations"),T=m.kernelShape.slice(),y=m.strides.slice(),w=v?m.dilations.slice():[],S=m.pads.slice();r.PoolConvUtil.adjustPoolAttributes(g,b,T,y,w,S);const O=r.PoolConvUtil.computePoolOutputShape(g,b,y,w,T,S,m.autoPad),P=Object.assign({},m);return v?Object.assign(P,{kernelShape:T,strides:y,pads:S,dilations:w,cacheKey:m.cacheKey}):Object.assign(P,{kernelShape:T,strides:y,pads:S,cacheKey:m.cacheKey}),[P,O]},f={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},h={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[o.TextureType.unpacked]};e.globalMaxPool=(_,m)=>(u(m),[_.run(Object.assign(Object.assign({},h),{get:()=>l(m,h,!0,f)}),m)]);const u=_=>{if(!_||_.length!==1)throw new Error("Pool ops requires 1 input.");if(_[0].type!=="float32"&&_[0].type!=="float64")throw new Error("Invalid input type.")},i=(_,m,g,b,v)=>{const T=_.length;if(m.kernelShape.length<=2){const y=m.kernelShape[m.kernelShape.length-1],w=m.strides[m.strides.length-1],S=m.pads[m.pads.length/2-1],O=m.pads[m.pads.length-1],P=_[T-1];let E="",A="",$="";if(E=S+O!==0?`
          for (int i = 0; i < ${y}; i++) {
            x[${T} - 1] = indices[${T} - 1] * ${w} - ${S} + i;
            if (x[${T} - 1] < 0 || x[${T} - 1] >= ${P}) {
              pad++;
              continue;
            }
            ${g}
          }`:`
          for (int i = 0; i < ${y}; i++) {
            x[${T} - 1] = indices[${T} - 1] * ${w} - ${S} + i;
            ${g}
          }`,m.kernelShape.length===2){const k=m.kernelShape[m.kernelShape.length-2],D=m.strides[m.strides.length-2],I=m.pads[m.pads.length/2-2],C=m.pads[m.pads.length-2],L=_[T-2];A=I+C!==0?`
            for (int j = 0; j < ${k}; j++) {
              x[${T} - 2] = indices[${T} - 2] * ${D} - ${I} + j;
              if (x[${T} - 2] < 0 || x[${T} - 2] >= ${L}) {
                pad+= ${y};
                continue;
              }
          `:`
            for (int j = 0; j < ${k}; j++) {
              x[${T} - 2] = indices[${T} - 2] * ${D} - ${I} + j;
            `,$=`
          }
        `}return`
        float process(int indices[${T}]) {
          int x[${T}];
          copyVec(indices, x);

          float value = ${v};
          int pad = 0;
          ${A}
          ${E}
          ${$}
          ${b}
          return value;
        }
      `}{const y=r.ShapeUtil.size(m.kernelShape),w=r.ShapeUtil.computeStrides(m.kernelShape),S=w.length,O=m.pads.length,P=p(S),E=d(_,"inputDims"),A=d(m.pads,"pads"),$=d(w,"kernelStrides"),k=d(m.strides,"strides");let D="";return D=m.pads.reduce((I,C)=>I+C)?`
            if (x[j] >= inputDims[j] || x[j] < 0) {
              pad++;
              isPad = true;
              break;
            }
          }
          if (!isPad) {
            ${g}
          }`:`
          }
          ${g}
        `,`
        ${P}
        float process(int indices[${T}]) {
          int x[${T}];
          copyVec(indices, x);
          int offset[${S}];
          int pads[${O}];
          int inputDims[${T}];
          int kernelStrides[${S}];
          int strides[${S}];
          ${A}
          ${E}
          ${k}
          ${$}

          float value = ${v};
          int pad = 0;
          bool isPad = false;
          for (int i = 0; i < ${y}; i++) {
            offsetToIndices(i, kernelStrides, offset);
            isPad = false;
            for (int j = ${T} - ${S}; j < ${T}; j++) {
              x[j] = indices[j] * strides[j - ${T} + ${S}]
                + offset[j - ${T} + ${S}] - pads[j - 2];
              ${D}
          }
          ${b}

          return value;
        }
      `}},d=(_,m)=>{let g="";for(let b=0;b<_.length;b++)g+=`
      ${m}[${b}] = ${_[b]};
    `;return g},p=_=>`
  void offsetToIndices(int offset, int[${_}] strides, out int[${_}] indices) {
    if (${_} == 0) {
      return;
    }
    for (int i = 0; i < ${_} - 1; ++i) {
      indices[i] = offset / strides[i];
      offset -= indices[i] * strides[i];
    }
    indices[${_} - 1] = offset;
  }`},1010:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.reduceLogSumSquare=e.reduceLogSum=e.reduceProd=e.reduceMin=e.reduceMax=e.reduceMean=e.reduceSum=e.parseReduceAttributes=void 0;const t=n(4910),r=n(6145),o=n(7273),s=n(5639),l=(h,u,i,d,p)=>{f(u);const _={name:d,inputNames:["A"],inputTypes:[s.TextureType.unpacked]};return[h.run(Object.assign(Object.assign({},_),{cacheHint:i.cacheKey,get:()=>c(h,u,i,d,p,_)}),u)]};e.parseReduceAttributes=h=>{const u=h.attributes.getInts("axes",[]),i=h.attributes.getInt("keepdims",1)===1;return(0,t.createAttributeWithCacheKey)({axes:u,keepDims:i})};const c=(h,u,i,d,p,_)=>{const m=[],g=u[0].dims.length||1,b=[],v=o.ShapeUtil.normalizeAxes(i.axes,u[0].dims.length),T=p(u,v);let y=T[1];for(let S=0;S<u[0].dims.length;S++)v.indexOf(S)>=0||v.length===0?(i.keepDims&&m.push(1),y=`
          for(int j${S} = 0; j${S} < ${u[0].dims[S]}; j${S}++) {
            inputIdx[${S}] = j${S};
            ${y}
          }`):(b.push(`inputIdx[${S}] = outputIdx[${m.length}];`),m.push(u[0].dims[S]));const w=`
      float process(int outputIdx[${m.length||1}]) {
        float value;                 // final result
        int inputIdx[${g}];      // addressing input data
        ${b.join(`
`)}
        ${T[0]}       // init ops for reduce max/min
        ${y}
        ${T[2]}       // final computation for reduce mean
        return value;
      }`;return Object.assign(Object.assign({},_),{output:{dims:m,type:u[0].type,textureType:s.TextureType.unpacked},shaderSource:w})},f=h=>{if(!h||h.length!==1)throw new Error("Reduce op requires 1 input.");if(r.NUMBER_TYPES.indexOf(h[0].type)===-1)throw new Error("Invalid input type.")};e.reduceSum=(h,u,i)=>l(h,u,i,"ReduceSum",()=>["value = 0.0;","value += _A(inputIdx);",""]),e.reduceMean=(h,u,i)=>l(h,u,i,"ReduceMean",(d,p)=>{let _=1;for(let m=0;m<d[0].dims.length;m++)(p.indexOf(m)>=0||p.length===0)&&(_*=d[0].dims[m]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${_}.;`]}),e.reduceMax=(h,u,i)=>l(h,u,i,"ReduceMax",(d,p)=>{const _=[];for(let m=0;m<d[0].dims.length;m++)(p.indexOf(m)>=0||p.length===0)&&_.push(`inputIdx[${m}] = 0;`);return[`${_.join(`
`)}
value = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]}),e.reduceMin=(h,u,i)=>l(h,u,i,"ReduceMin",(d,p)=>{const _=[];for(let m=0;m<d[0].dims.length;m++)(p.indexOf(m)>=0||p.length===0)&&_.push(`inputIdx[${m}] = 0;`);return[`${_.join(`
`)}
value = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]}),e.reduceProd=(h,u,i)=>l(h,u,i,"ReduceProd",()=>["value = 1.0;","value *= _A(inputIdx);",""]),e.reduceLogSum=(h,u,i)=>l(h,u,i,"ReduceLogSum",()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"]),e.reduceLogSumSquare=(h,u,i)=>l(h,u,i,"ReduceLogSumSquare",()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""])},7379:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isReshapeCheap=e.processDims3D=e.createPackedReshape3DProgramInfoLoader=void 0;const t=n(7273),r=n(6757),o=n(5639),s=n(5614);e.createPackedReshape3DProgramInfoLoader=(l,c,f)=>{const h=(u=>({name:"Reshape (packed)",inputTypes:[o.TextureType.packed],inputNames:["A"],cacheHint:`${u}`}))(f);return Object.assign(Object.assign({},h),{get:()=>((u,i,d,p)=>{const _=i.dims,m=p;let g="";for(let T=0;T<4;T++){let y="";switch(T){case 0:y="outputCoords = rc;";break;case 1:y="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:y="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:y="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}g+=`
        ${y}
        ${T>0?"if(outputCoords.y < rows && outputCoords.z < cols){":""}
          int flattenedIndex = getFlattenedIndex(outputCoords);

          ivec3 inputRC = inputCoordsFromReshapedOutCoords(flattenedIndex);
          vec2 innerDims = vec2(float(inputRC.y),float(inputRC.z));

          result[${T}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims);

        ${T>0?"}":""}
      `}const b=(0,r.getGlsl)(u.session.backend.glContext.version),v=`
      ${function(T){const y=t.ShapeUtil.computeStrides(T),w=["b","r","c"],S="index";return`
    ivec3 inputCoordsFromReshapedOutCoords(int index) {
      ${y.map((O,P)=>`int ${w[P]} = ${S} / ${O}; ${P===y.length-1?`int ${w[P+1]} = ${S} - ${w[P]} * ${O}`:`index -= ${w[P]} * ${O}`};`).join("")}
      return ivec3(b, r, c);
    }
  `}(_)}
      ${function(T){const y=t.ShapeUtil.computeStrides(T);return`
  int getFlattenedIndex(ivec3 coords) {
    // reverse y, z order
    return coords.x * ${y[0]} + coords.z * ${y[1]} + coords.y;
  }
`}(m)}
      ${(0,s.unpackFromChannel)()}

      void main() {
        ivec3 rc = getOutputCoords();

        vec4 result = vec4(0.0);

        ivec3 outputCoords;
        int rows = ${m[2]};
        int cols = ${m[1]};

        ${g}
        ${b.output} = result;
      }
    `;return Object.assign(Object.assign({},d),{output:{dims:m,type:i.type,textureType:o.TextureType.packed},shaderSource:v,hasMain:!0})})(l,c,h,f)})},e.processDims3D=function(l){if(l.length===0)return[1,1,1];let c=1;for(let f=0;f<l.length-2;++f)c*=l[f];return[c,l.length>1?l[l.length-2]:1,l[l.length-1]]},e.isReshapeCheap=function(l,c){let f=!1;return f=l.length===0||c.length===0||(l.length<2||c.length<2?l[l.length-1]===c[c.length-1]:l[l.length-1]===c[c.length-1]&&l[l.length-2]===c[c.length-2]),f}},8126:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.reshape=void 0;const t=n(7273);e.reshape=(r,o)=>{const s=t.ShapeUtil.calculateReshapedDims(o[0].dims,o[1].integerData);return r.session.pack?[r.reshapePacked(o[0],s)]:[r.reshapeUnpacked(o[0],s)]}},2801:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseResizeAttributesV11=e.parseResizeAttributesV10=e.resize=void 0;const t=n(6757),r=n(5639),o=n(432),s=n(5614),l=n(3980),c={name:"Resize",inputNames:["A"],inputTypes:[r.TextureType.packed]};e.resize=(d,p,_)=>((0,l.validateInputs)(p,_),[d.run(Object.assign(Object.assign({},c),{cacheHint:_.cacheKey,get:()=>f(d,p,_)}),p)]),e.parseResizeAttributesV10=d=>(0,l.parseUpsampleAttributes)(d,10),e.parseResizeAttributesV11=d=>(0,l.parseUpsampleAttributes)(d,11);const f=(d,p,_)=>{const m=(0,t.getGlsl)(d.session.backend.glContext.version),[g,b]=h(p,_);if(g.every(D=>D===1)&&_.coordinateTransformMode!=="tf_crop_and_resize")return Object.assign(Object.assign({},c),{output:{dims:b,type:p[0].type,textureType:r.TextureType.packed},hasMain:!0,shaderSource:`void main() {
                    vec4 v = ${m.texture2D}(X, TexCoords);
                    ${m.output} = v;
                }`});const v=b.length;if(v<2)throw new Error(`output dimension should be at least 2, but got ${v}`);const T=b[v-2],y=b[v-1],w=p[0].dims;if(v!==w.length)throw new Error(`output dimension should match input ${w.length}, but got ${v}`);const S=w[v-2],O=w[v-1],P=g[v-2],E=g[v-1];let A="";if(_.mode!=="linear")throw new Error(`resize (packed) does not support mode: '${_.mode}'`);switch(_.coordinateTransformMode){case"asymmetric":A=`
                    vec4 getSourceFracIndex(ivec4 coords) {
                        return vec4(coords) / scaleWHWH;
                    }
                `;break;case"half_pixel":A=`
                    vec4 getSourceFracIndex(ivec4 coords) {
                        return (vec4(coords) + 0.5) / scaleWHWH - 0.5;
                    }
                `;break;case"pytorch_half_pixel":A=`
                    vec4 getSourceFracIndex(ivec4 coords) {
                        vec4 fcoords = vec4(coords);
                        return vec4(
                            ${y}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0,
                            ${T}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0,
                            ${y}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0,
                            ${T}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0
                          );
                    }
                `;break;case"align_corners":A=`
                    vec4 getSourceFracIndex(ivec4 coords) {
                        vec4 resized = vec4(${y}.0 - 1.0, ${T}.0 - 1.0, ${y}.0 - 1.0,
                            ${T}.0 - 1.0);
                        vec4 original = vec4(${O}.0 - 1.0, ${S}.0 - 1.0, ${O}.0 - 1.0,
                            ${S}.0 - 1.0);
                        vec4 new_scale = original / resized;
                        return vec4(coords) * new_scale;
                    }
                `;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode:                                 '${_.coordinateTransformMode}'`)}const $=(0,o.getCoordsDataType)(v),k=`
            const vec2 inputWH = vec2(${S}.0, ${O}.0);
            const vec4 scaleWHWH = vec4(float(${P}), float(${E}), float(${P}), float(${E}));
            ${(0,s.unpackFromChannel)()}
            ${A}
            float getAValue(int x10, int r, int c, int d) {
                return getChannel(getA(x10, r, c, d), vec2(c, d));
            }
            void main() {
                ${$} rc = getOutputCoords();

                int batch = rc[0];
                int depth = rc[1];

                // retrieve the 4 coordinates that is used in the 4 packed output values.
                ivec4 coords = ivec4(rc.wz, rc.w + 1, rc.z + 1);

                // calculate the source index in fraction
                vec4 sourceFrac = getSourceFracIndex(coords);

                // get the lower and upper bound of the 4 values that will be packed into one texel.
                ivec4 x00 = ivec4(max(sourceFrac.xy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xy)));
                ivec4 x01 = ivec4(max(sourceFrac.xw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xw)));
                ivec4 x10 = ivec4(max(sourceFrac.zy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zy)));
                ivec4 x11 = ivec4(max(sourceFrac.zw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zw)));

                bool hasNextRow = rc.w < ${T-1};
                bool hasNextCol = rc.z < ${y-1};

                // pack x00, x01, x10, x11's top-left corner into one vec4 structure
                vec4 topLeft = vec4(
                    getAValue(batch, depth, x00.x, x00.y),
                    hasNextCol ? getAValue(batch, depth, x01.x, x01.y) : 0.0,
                    hasNextRow ? getAValue(batch, depth, x10.x, x10.y) : 0.0,
                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.y) : 0.0);

                // pack x00, x01, x10, x11's top-right corner into one vec4 structure
                vec4 topRight = vec4(
                    getAValue(batch, depth, x00.x, x00.w),
                    hasNextCol ? getAValue(batch, depth, x01.x, x01.w) : 0.0,
                    hasNextRow ? getAValue(batch, depth, x10.x, x10.w) : 0.0,
                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.w) : 0.0);

                // pack x00, x01, x10, x11's bottom-left corner into one vec4 structure
                vec4 bottomLeft = vec4(
                    getAValue(batch, depth, x00.z, x00.y),
                    hasNextCol ? getAValue(batch, depth, x01.z, x01.y) : 0.0,
                    hasNextRow ? getAValue(batch, depth, x10.z, x10.y) : 0.0,
                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.y) : 0.0);

                // pack x00, x01, x10, x11's bottom-right corner into one vec4 structure
                vec4 bottomRight = vec4(
                    getAValue(batch, depth, x00.z, x00.w),
                    hasNextCol ? getAValue(batch, depth, x01.z, x01.w) : 0.0,
                    hasNextRow ? getAValue(batch, depth, x10.z, x10.w) : 0.0,
                    (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.w) : 0.0);

                // calculate the interpolation fraction on u and v direction
                vec4 frac = vec4(sourceFrac) - floor(sourceFrac);
                vec4 clampFrac = clamp(frac, vec4(0.0), vec4(1.0));

                vec4 top = mix(topLeft, topRight, clampFrac.ywyw);
                vec4 bottom = mix(bottomLeft, bottomRight, clampFrac.ywyw);
                vec4 newValue = mix(top, bottom, clampFrac.xxzz);

                ${m.output} = vec4(newValue);
            }
        `;return Object.assign(Object.assign({},c),{output:{dims:b,type:p[0].type,textureType:r.TextureType.packed},hasMain:!0,shaderSource:k})},h=(d,p)=>{const _=d[0].dims;let m,g=p.scales;if(g.length===0){const v=d[p.scalesInputIdx];if(v&&v.size!==0){if(d[p.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");g=u(v,p.mode,p.isResize)}else{const T=d[p.sizesInputIdx];if(!T||T.size===0)throw new Error("Either scales or sizes MUST be provided as input.");m=Array.from(T.integerData),g=i(m,_,p.mode,p.isResize)}}else if(d[p.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");const b=m||_.map((v,T)=>Math.floor(v*g[T]));return[g,b]},u=(d,p,_)=>{const m=Array.from(d.floatData);return(0,l.scalesValidation)(m,p,_),m},i=(d,p,_,m)=>{const g=p.length,b=new Array(g);for(let v=0,T=g;v<T;v++)if(p[v]===0){if(d[v]!==0)throw new Error("Input dim is zero but required output dim is non-zero.");b[v]=1}else b[v]=d[v]/p[v];return(0,l.scalesValidation)(b,_,m),b}},565:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.shape=void 0;const t=n(9240);e.shape=(o,s)=>(r(s),[new t.Tensor([s[0].dims.length],"int32",void 0,void 0,new Int32Array(s[0].dims))]);const r=o=>{if(!o||o.length!==1)throw new Error("Shape requires 1 input.")}},2444:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sliceV10=e.parseSliceAttributes=e.slice=void 0;const t=n(4910),r=n(6145),o=n(7273),s=n(5639),l={name:"Slice",inputNames:["A"],inputTypes:[s.TextureType.unpacked]};e.slice=(i,d,p)=>(f(d),[i.run(Object.assign(Object.assign({},l),{cacheHint:p.cacheKey,get:()=>c(i,d[0],p)}),d)]),e.parseSliceAttributes=i=>{const d=i.attributes.getInts("starts"),p=i.attributes.getInts("ends"),_=i.attributes.getInts("axes",[]);return(0,t.createAttributeWithCacheKey)({starts:d,ends:p,axes:_})};const c=(i,d,p)=>{const _=p.axes.length===0?d.dims.slice(0).map((w,S)=>S):p.axes,m=o.ShapeUtil.normalizeAxes(_,d.dims.length),g=p.starts.map((w,S)=>w>d.dims[m[S]]-1?d.dims[m[S]]:o.ShapeUtil.normalizeAxis(w,d.dims[m[S]])),b=p.ends.map((w,S)=>w>d.dims[m[S]]-1?d.dims[m[S]]:o.ShapeUtil.normalizeAxis(w,d.dims[m[S]])),v=d.dims.slice(),T=[];for(let w=0;w<m.length;w++)v[m[w]]=b[w]-g[w],g[w]>0&&T.push(`outputIdx[${m[w]}] += ${g[w]};`);const y=`
      float process(int outputIdx[${v.length}]) {
        ${T.join(`
      `)}
        return _A(outputIdx);
      }`;return Object.assign(Object.assign({},l),{output:{dims:v,type:d.type,textureType:s.TextureType.unpacked},shaderSource:y})},f=i=>{if(!i||i.length!==1)throw new Error("Slice requires 1 input.");if(r.NUMBER_TYPES.indexOf(i[0].type)===-1)throw new Error("Invalid input type.")};e.sliceV10=(i,d)=>{u(d);const p=h(i,d);return[i.run(Object.assign(Object.assign({},l),{cacheHint:p.cacheKey,get:()=>c(i,d[0],p)}),[d[0]])]};const h=(i,d)=>{if(!i.session.isInitializer(d[1].dataId)||!i.session.isInitializer(d[2].dataId)||d.length>=4&&!i.session.isInitializer(d[3].dataId)||d.length>=5&&!i.session.isInitializer(d[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(d.length>=5&&d[4].integerData.some(g=>g!==1))throw new Error("currently non-1 steps is not supported for Slice");const p=Array.from(d[1].integerData),_=Array.from(d[2].integerData),m=d.length>=4?Array.from(d[3].integerData):[];return{starts:p,ends:_,axes:m,cacheKey:`${m};${p};${_}`}},u=i=>{if(!i||i.length<3||i.length>5)throw new Error("Invalid input number.");if(i[1].type!=="int32"||i[1].dims.length!==1)throw new Error("Invalid input type.");if(i[2].type!=="int32"||i[2].dims.length!==1)throw new Error("Invalid input type.");if(i.length>=4&&(i[3].type!=="int32"||i[3].dims.length!==1))throw new Error("Invalid input type.");if(i.length>=5&&(i[4].type!=="int32"||i[4].dims.length!==1))throw new Error("Invalid input type.")}},815:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.softmaxV13=e.parseSoftmaxAttributesV13=e.parseSoftmaxAttributes=e.softmax=void 0;const t=n(4910),r=n(7273),o=n(6757),s=n(5639),l=n(5707),c={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[s.TextureType.unpacked]},f={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[s.TextureType.unpacked,s.TextureType.unpacked]},h={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[s.TextureType.unpacked,s.TextureType.unpacked,s.TextureType.unpacked]};e.softmax=(m,g,b)=>{_(g);const v=g[0].dims.slice(),T=r.ShapeUtil.normalizeAxis(b.axis,v.length),y=r.ShapeUtil.sizeToDimension(v,T),w=r.ShapeUtil.sizeFromDimension(v,T);return u(m,g,b,y,w)},e.parseSoftmaxAttributes=m=>(0,t.createAttributeWithCacheKey)({axis:m.attributes.getInt("axis",1)}),e.parseSoftmaxAttributesV13=m=>(0,t.createAttributeWithCacheKey)({axis:m.attributes.getInt("axis",-1)}),e.softmaxV13=(m,g,b)=>{_(g);const v=g[0].dims.slice(),T=r.ShapeUtil.normalizeAxis(b.axis,v.length),y=v.length,w=T!==y-1,S=[];let O,P=[],E=[];w&&(P=Array.from({length:y}).map((D,I)=>I),P[T]=y-1,P[y-1]=T,P.map(D=>S.push(v[D])),O=(0,t.createAttributeWithCacheKey)({perm:P}),E=(0,l.transpose)(m,g,O));const A=w?r.ShapeUtil.sizeToDimension(S,y-1):r.ShapeUtil.sizeToDimension(v,y-1),$=w?r.ShapeUtil.sizeFromDimension(S,y-1):r.ShapeUtil.sizeFromDimension(v,y-1),k=u(m,w?E:g,b,A,$);return w?(0,l.transpose)(m,k,O):k};const u=(m,g,b,v,T)=>{const y=i(m,g[0],v,T,[v]),w=m.run(Object.assign(Object.assign({},c),{cacheHint:b.cacheKey,get:()=>y}),g),S=d(m,g[0],v,T,y.output.dims,[v]),O=m.run(Object.assign(Object.assign({},f),{cacheHint:b.cacheKey,get:()=>S}),[g[0],w]),P=p(m,g[0],v,T,y.output.dims,S.output.dims);return[m.run(Object.assign(Object.assign({},h),{cacheHint:b.cacheKey,get:()=>P}),[g[0],w,O])]},i=(m,g,b,v,T)=>{const[y,w]=m.calculateTextureWidthAndHeight(g.dims,s.TextureType.unpacked),S=T.length;if(b<1||v<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(T.length!==1)throw new Error("Dimensionality of the output should be 1");if(T[0]!==b)throw new Error("Shape of the output should be equal to logical row count");const O=(0,o.getGlsl)(m.session.backend.glContext.version),P=`
      float process(int[${S}] indices) {
        int logical_row_start_offset = indices[0] * ${v};

        float max = getColorAsFloat(${O.texture2D}(A, offsetToCoords(logical_row_start_offset, ${y},
        ${w} )));
        for(int i=1; i<${v}; ++i)
        {
          float current = getColorAsFloat(${O.texture2D}(A, offsetToCoords(logical_row_start_offset + i,
            ${y}, ${w})));
          if(current > max)
          max = current;
        }

        return max;
      }`;return Object.assign(Object.assign({},c),{output:{dims:T,type:g.type,textureType:s.TextureType.unpacked},shaderSource:P})},d=(m,g,b,v,T,y)=>{const[w,S]=m.calculateTextureWidthAndHeight(g.dims,s.TextureType.unpacked),O=y.length;if(b<1||v<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(y.length!==1)throw new Error("Dimensionality of the output should be 1");if(y[0]!==b)throw new Error("Shape of the output should be equal to logical row count");if(T.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(T[0]!==b)throw new Error("Shape of the intermediate results should be equal to logical row count");const P=`
      float process(int[${O}] indices) {
        int logical_row_start_offset = indices[0] * ${v};

        float norm_factor = 0.0;
        float max = _Max(indices);
        for(int i=0; i<${v}; ++i)
        {
          norm_factor += exp(getColorAsFloat(${(0,o.getGlsl)(m.session.backend.glContext.version).texture2D}(A, offsetToCoords(logical_row_start_offset + i,
            ${w}, ${S}))) - max);
        }

        return norm_factor;
      }`;return Object.assign(Object.assign({},f),{output:{dims:y,type:g.type,textureType:s.TextureType.unpacked},shaderSource:P})},p=(m,g,b,v,T,y)=>{const[w,S]=m.calculateTextureWidthAndHeight(g.dims,s.TextureType.unpacked),O=g.dims.length;if(b<1||v<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(T.length!==1||y.length!==1)throw new Error("Dimensionality of the intermediate results should be 1");if(T[0]!==b||y[0]!==b)throw new Error("Shape of the intermediate results should be equal to logical row count");const P=`
      float process(int[${O}] indices) {

      // get offset of current logical tensor index from the 2-D texture coordinates (TexCoords)
      int offset = coordsToOffset(TexCoords, ${w}, ${S});

      //determine the logical row for this index
      int logical_row_index[1];
      logical_row_index[0] = offset / ${v};

      float norm_factor = _Norm(logical_row_index);

      // avoid possible division by 0
      // if norm_facor is 0, all elements are zero
      // if so, return 0
      if(norm_factor == 0.0)
        return 0.0;

      return exp(_A(indices) - _Max(logical_row_index)) / norm_factor;
    }`;return Object.assign(Object.assign({},h),{output:{dims:g.dims,type:g.type,textureType:s.TextureType.unpacked},shaderSource:P})},_=m=>{if(!m||m.length!==1)throw new Error("Softmax requires 1 input.");if(m[0].type!=="float32"&&m[0].type!=="float64")throw new Error("Invalid input type")}},564:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseSplitAttributes=e.split=void 0;const t=n(4910),r=n(7273),o=n(5639),s={name:"Split",inputNames:["A"],inputTypes:[o.TextureType.unpacked]};e.split=(h,u,i)=>{f(u);const d=r.ShapeUtil.normalizeAxis(i.axis,u[0].dims.length),p=l(h,u,d,i),_=[];for(let m=0;m<p;++m)_.push(h.run(Object.assign(Object.assign({},s),{cacheHint:`${i.cacheKey};${m}`,get:()=>c(h,u[0],i,d,m)}),u));return _},e.parseSplitAttributes=h=>{const u=h.attributes.getInt("axis",0),i=h.attributes.getInts("split",[]),d=h.outputs.length;return(0,t.createAttributeWithCacheKey)({axis:u,split:i,numOutputs:d})};const l=(h,u,i,d)=>{const[,p]=r.SplitUtil.splitShape(u[0].dims,i,d.split,d.numOutputs);return p.length},c=(h,u,i,d,p)=>{const[_,m]=r.SplitUtil.splitShape(u.dims,d,i.split,i.numOutputs),g=m[p],b=_[p],v=`
      float process(int indices[${b.length}]) {
        indices[${d}] += ${g};
        return _A(indices);
      }
    `;return Object.assign(Object.assign({},s),{cacheHint:`${i.cacheKey}:${p}`,output:{dims:b,type:u.type,textureType:o.TextureType.unpacked},shaderSource:v})},f=h=>{if(!h||h.length!==1)throw new Error("Split requires one input.");if(h[0].type!=="int8"&&h[0].type!=="uint8"&&h[0].type!=="int16"&&h[0].type!=="uint16"&&h[0].type!=="int32"&&h[0].type!=="uint32"&&h[0].type!=="float32"&&h[0].type!=="float64"&&h[0].type!=="bool")throw new Error("Invalid input type.")}},5416:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseSqueezeAttributes=e.squeezeV13=e.squeeze=void 0;const t=n(7273);e.squeeze=(s,l,c)=>{r(l);const f=t.ShapeUtil.squeezeShape(l[0].dims,c);return[s.reshapeUnpacked(l[0],f)]},e.squeezeV13=(s,l)=>(o(l),(0,e.squeeze)(s,[l[0]],Array.from(l[1].integerData))),e.parseSqueezeAttributes=s=>s.attributes.getInts("axes");const r=s=>{if(!s||s.length!==1)throw new Error("Squeeze requires 1 input.");if(s[0].type==="string")throw new Error("invalid input tensor types.")},o=s=>{if(!s||s.length!==2)throw new Error("Squeeze requires 2 inputs.");if(s[1].type!=="int32")throw new Error("Invalid input type.")}},1240:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sum=void 0;const t=n(6757),r=n(5639);e.sum=(l,c)=>{s(c);const f={name:"Sum",inputNames:c.map((h,u)=>`X${u}`),inputTypes:new Array(c.length).fill(r.TextureType.unpacked)};return[l.run(Object.assign(Object.assign({},f),{get:()=>o(l,c,f)}),c)]};const o=(l,c,f)=>{const h=(0,t.getGlsl)(l.session.backend.glContext.version),u=c[0].dims.slice(),i=`
      void main() {
        vec4 result = ${c.map((d,p)=>`${h.texture2D}(X${p},TexCoords)`).join(" + ")};
        ${h.output} = result;
      }
    `;return Object.assign(Object.assign({},f),{output:{dims:u,type:c[0].type,textureType:r.TextureType.unpacked},hasMain:!0,shaderSource:i})},s=l=>{if(!l||l.length===0)throw new Error("Sum requires inputs.");const c=l[0].dims.length;for(let f=1;f<l.length;f++){if(c!==l[f].dims.length)throw new Error("Input shapes are mismatched.");for(let h=0;h<c;h++)if(l[0].dims[h]!==l[f].dims[h])throw new Error("Input shapes are not matched.")}if(l[0].type!=="float32"&&l[0].type!=="float64")throw new Error("Invalid input type.");for(let f=1;f<l.length;f++)if(l[0].type!==l[f].type)throw new Error("Input types are not matched.")}},5944:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tile=void 0;const t=n(6145),r=n(5639);e.tile=(l,c)=>{s(c);const f={name:"Tile",inputNames:["A"],inputTypes:[r.TextureType.unpacked]};return[l.run(Object.assign(Object.assign({},f),{get:()=>o(l,c,f)}),c)]};const o=(l,c,f)=>{const h=c[0].dims.slice(),u=new Array(h.length),i=[];for(let _=0;_<h.length;_++)u[_]=h[_]*c[1].numberData[_],i.push(`inputIdx[${_}] = int(mod(float(outputIdx[${_}]), ${h[_]}.));`);const d=u.length,p=`
      float process(int outputIdx[${d}]) {
        int inputIdx[${d}];
        ${i.join(`
`)}
        return _A(inputIdx);
      }
    `;return Object.assign(Object.assign({},f),{output:{dims:u,type:c[0].type,textureType:r.TextureType.unpacked},shaderSource:p})},s=l=>{if(!l||l.length!==2)throw new Error("Tile requires 2 input.");if(l[1].dims.length!==1)throw new Error("The second input shape must 1 dimension.");if(l[1].dims[0]!==l[0].dims.length)throw new Error("Invalid input shape.");if(t.NUMBER_TYPES.indexOf(l[0].type)===-1)throw new Error("Invalid input type.");if(l[1].type!=="int32"&&l[1].type!=="int16")throw new Error("Invalid repeat type.")}},5707:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseTransposeAttributes=e.transpose=void 0;const t=n(4910),r=n(7273),o=n(5639),s={name:"Transpose",inputNames:["A"],inputTypes:[o.TextureType.unpacked]};e.transpose=(i,d,p)=>(u(d),[i.run(Object.assign(Object.assign({},s),{cacheHint:p.cacheKey,get:()=>l(i,d[0],p.perm)}),d)]),e.parseTransposeAttributes=i=>(0,t.createAttributeWithCacheKey)({perm:i.attributes.getInts("perm",[])});const l=(i,d,p)=>{const _=d.dims;p=c(_,p);const m=f(_,p),g=_.length,b=`
      ${h("perm",p,g)}
      float process(int indices[${g}]) {
        int a[${g}];
        perm(a, indices);
        return _A(a);
      }`;return Object.assign(Object.assign({},s),{output:{dims:m,type:d.type,textureType:o.TextureType.unpacked},shaderSource:b})},c=(i,d)=>(d&&d.length!==i.length&&(d=[...i.keys()].reverse()),d),f=(i,d)=>(d=c(i,d),r.ShapeUtil.sortBasedOnPerm(i,d)),h=(i,d,p)=>{const _=[];_.push(`void ${i}(out int a[${p}], int src[${p}]) {`);for(let m=0;m<p;++m)_.push(`	a[${d[m]}]=src[${m}];`);return _.push("	}"),_.join(`
`)},u=i=>{if(!i||i.length!==1)throw new Error("Transpose requires 1 input.");if(i[0].type!=="float32"&&i[0].type!=="float64")throw new Error("input should be float tensor")}},2488:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.encodeAsUint8=void 0;const t=n(6757),r=n(5639);e.encodeAsUint8=(o,s)=>{const l=s.shape,c=(0,t.getGlsl)(o.session.backend.glContext.version),f=`
    const float FLOAT_MAX = 1.70141184e38;
    const float FLOAT_MIN = 1.17549435e-38;

    bool isNaN(float val) {
      return (val < 1.0 || 0.0 < val || val == 0.0) ? false : true;
    }

    highp vec4 encodeAsUint8(highp float v) {
      if (isNaN(v)) {
        return vec4(255, 255, 255, 255);
      }

      highp float av = abs(v);

      if(av < FLOAT_MIN) {
        return vec4(0.0, 0.0, 0.0, 0.0);
      } else if(v > FLOAT_MAX) {
        return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;
      } else if(v < -FLOAT_MAX) {
        return vec4(0.0, 0.0,  128.0, 255.0) / 255.0;
      }

      highp vec4 c = vec4(0,0,0,0);

      highp float e = floor(log2(av));
      highp float m = exp2(fract(log2(av))) - 1.0;

      c[2] = floor(128.0 * m);
      m -= c[2] / 128.0;
      c[1] = floor(32768.0 * m);
      m -= c[1] / 32768.0;
      c[0] = floor(8388608.0 * m);

      highp float ebias = e + 127.0;
      c[3] = floor(ebias / 2.0);
      ebias -= c[3] * 2.0;
      c[2] += floor(ebias) * 128.0;

      c[3] += 128.0 * step(0.0, -v);

      return c / 255.0;
    }

    void main() {
      float value = ${c.texture2D}(X,TexCoords).r;
      ${c.output} = encodeAsUint8(value);
    }`,h={name:"Uint8Encode",inputTypes:[r.TextureType.unpacked],inputNames:["X"],output:{dims:l,type:s.tensor.type,textureType:r.TextureType.downloadUint8AsFloat},shaderSource:f,hasMain:!0};return o.executeProgram(h,[s.tensor])}},9087:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tanh=e.tan=e.sqrt=e.sin=e.sigmoid=e.relu=e.not=e.neg=e.log=e.parseLeakyReluAttributes=e.leakyRelu=e.identity=e.floor=e.exp=e.parseEluAttributes=e.elu=e.cos=e.ceil=e.clipV11=e.parseClipAttributes=e.clip=e.atan=e.asin=e.acos=e.abs=e.glslTanh=e.glslTan=e.glslSqrt=e.glslSigmoid=e.glslRelu=e.glslSin=e.glslNot=e.glslNeg=e.glslLog=e.glslLeakyRelu=e.glslIdentity=e.glslClip=e.glslFloor=e.glslExp=e.glslElu=e.glslCos=e.glslCeil=e.glslAtan=e.glslAsin=e.glslAcos=e.glslAbs=void 0;const t=n(4910),r=n(7273),o=n(1997),s=n(6757),l=n(5639);function c(){return k("abs")}function f(){return k("acos")}function h(){return k("asin")}function u(){return k("atan")}function i(){return k("ceil")}function d(){return k("cos")}function p(C){const L="elu";return{body:`
  const float alpha = float(${C});

  float ${L}_(float a) {
    return a >= 0.0 ? a: (exp(a) - 1.0) * alpha;
  }
  vec4 ${L}_(vec4 v) {
    return vec4(${L}_(v.x), ${L}_(v.y), ${L}_(v.z), ${L}_(v.w));
  }
  `,name:L,type:o.FunctionType.ValueBased}}function _(){return k("exp")}function m(){return k("floor")}function g(C,L){const K="clip";return{body:`
  const float min = float(${C});
  const float max = float(${L});

  float ${K}_(float a) {
    return clamp(a, min, max);
  }
  vec4 ${K}_(vec4 v) {
    return clamp(v, min, max);
  }
  `,name:K,type:o.FunctionType.ValueBased}}function b(){const C="indentity";return{body:`
  float ${C}_(float a) {
    return a;
  }
  vec4 ${C}_(vec4 v) {
    return v;
  }
  `,name:C,type:o.FunctionType.ValueBased}}function v(C){const L="leakyRelu";return{body:`
  const float alpha = float(${C});

  float ${L}_(float a) {
    return a < 0.0 ? a * alpha : a;
  }
  vec4 ${L}_(vec4 v) {
    return vec4(${L}_(v.x), ${L}_(v.y), ${L}_(v.z), ${L}_(v.w));
  }
  `,name:L,type:o.FunctionType.ValueBased}}function T(){return k("log")}function y(){const C="neg";return{body:`
  float ${C}_(float a) {
    return -a;
  }
  vec4 ${C}_(vec4 v) {
    return -v;
  }
  `,name:C,type:o.FunctionType.ValueBased}}function w(){const C="not";return{body:`
  float ${C}_(float a) {
    return float( ! bool(a) );
  }
  bool ${C}_(bool a) {
    return !a;
  }
  vec4 ${C}_(vec4 v) {
    return vec4(!bool(v.x), !bool(v.y), !bool(v.z), !bool(v.w));
  }
  bvec4 ${C}_(bvec4 v) {
    return bvec4(!v.x, !v.y, !v.z, !v.w);
  }
  `,name:C,type:o.FunctionType.ValueBased}}function S(){return k("sin")}function O(){const C="relu";return{body:`
  float ${C}_(float a) {
    return max( a, 0.0 );
  }
  vec4 ${C}_(vec4 v) {
    return max( v, 0.0 );
  }
  `,name:C,type:o.FunctionType.ValueBased}}function P(){const C="sigmoid";return{body:`
  float ${C}_(float a) {
    return 1.0 / (1.0 + exp(-a));
  }
  vec4 ${C}_(vec4 v) {
    return 1.0 / (1.0 + exp(-v));
  }
  `,name:C,type:o.FunctionType.ValueBased}}function E(){return k("sqrt")}function A(){return k("tan")}function $(){const C="tanh";return{body:`
  float ${C}_(float a) {
    a = clamp(a, -10., 10.);
    a = exp(2.*a);
    return (a - 1.) / (a + 1.);
  }
  vec4 ${C}_(vec4 v) {
    v = clamp(v, -10., 10.);
    v = exp(2.*v);
    return (v - 1.) / (v + 1.);
  }
  `,name:C,type:o.FunctionType.ValueBased}}function k(C){return{body:`
  float ${C}_(float a) {
    return ${C}(a);
  }
  vec4 ${C}_(vec4 v) {
    return ${C}(v);
  }
  `,name:C,type:o.FunctionType.ValueBased}}e.glslAbs=c,e.glslAcos=f,e.glslAsin=h,e.glslAtan=u,e.glslCeil=i,e.glslCos=d,e.glslElu=p,e.glslExp=_,e.glslFloor=m,e.glslClip=g,e.glslIdentity=b,e.glslLeakyRelu=v,e.glslLog=T,e.glslNeg=y,e.glslNot=w,e.glslSin=S,e.glslRelu=O,e.glslSigmoid=P,e.glslSqrt=E,e.glslTan=A,e.glslTanh=$;const D=(C,L,K,G)=>{const J=C.session.pack?l.TextureType.packed:l.TextureType.unpacked,Y={name:K.name,inputTypes:[J],inputNames:["A"],cacheHint:G};return Object.assign(Object.assign({},Y),{get:()=>((te,ee,ie,ae)=>{const ue=te.session.pack?l.TextureType.packed:l.TextureType.unpacked,fe=(0,s.getGlsl)(te.session.backend.glContext.version);return Object.assign(Object.assign({},ee),{output:{dims:ie.dims,type:ie.type,textureType:ue},shaderSource:`
     ${ae.body}
     void main() {
       vec4 v = ${fe.texture2D}(A, TexCoords);
       v = ${ae.name}_(v);
       ${fe.output} = v;
     }
     `,hasMain:!0})})(C,Y,L,K)})};e.abs=(C,L)=>[C.run(D(C,L[0],c()),L)],e.acos=(C,L)=>[C.run(D(C,L[0],f()),L)],e.asin=(C,L)=>[C.run(D(C,L[0],h()),L)],e.atan=(C,L)=>[C.run(D(C,L[0],u()),L)],e.clip=(C,L,K)=>[C.run(D(C,L[0],g(K.min,K.max),K.cacheKey),L)],e.parseClipAttributes=C=>(0,t.createAttributeWithCacheKey)({min:C.attributes.getFloat("min",r.MIN_CLIP),max:C.attributes.getFloat("max",r.MAX_CLIP)}),e.clipV11=(C,L)=>{const K=I(C,L);return(0,e.clip)(C,[L[0]],K)};const I=(C,L)=>{if(L.length>=3&&(!C.session.isInitializer(L[1].dataId)||!C.session.isInitializer(L[2].dataId)))throw new Error("dynamic clip attributes are not allowed");const K=L.length>=3?L[1].numberData[0]:r.MIN_CLIP,G=L.length>=3?L[2].numberData[0]:r.MAX_CLIP;return(0,t.createAttributeWithCacheKey)({min:K,max:G})};e.ceil=(C,L)=>[C.run(D(C,L[0],i()),L)],e.cos=(C,L)=>[C.run(D(C,L[0],d()),L)],e.elu=(C,L,K)=>[C.run(D(C,L[0],p(K.alpha),K.cacheKey),L)],e.parseEluAttributes=C=>(0,t.createAttributeWithCacheKey)({alpha:C.attributes.getFloat("alpha",1)}),e.exp=(C,L)=>[C.run(D(C,L[0],_()),L)],e.floor=(C,L)=>[C.run(D(C,L[0],m()),L)],e.identity=(C,L)=>[C.run(D(C,L[0],b()),L)],e.leakyRelu=(C,L,K)=>[C.run(D(C,L[0],v(K.alpha),K.cacheKey),L)],e.parseLeakyReluAttributes=C=>(0,t.createAttributeWithCacheKey)({alpha:C.attributes.getFloat("alpha",.01)}),e.log=(C,L)=>[C.run(D(C,L[0],T()),L)],e.neg=(C,L)=>[C.run(D(C,L[0],y()),L)],e.not=(C,L)=>[C.run(D(C,L[0],w()),L)],e.relu=(C,L)=>[C.run(D(C,L[0],O()),L)],e.sigmoid=(C,L)=>[C.run(D(C,L[0],P()),L)],e.sin=(C,L)=>[C.run(D(C,L[0],S()),L)],e.sqrt=(C,L)=>[C.run(D(C,L[0],E()),L)],e.tan=(C,L)=>[C.run(D(C,L[0],A()),L)],e.tanh=(C,L)=>[C.run(D(C,L[0],$()),L)]},540:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createUnpackProgramInfoLoader=e.createUnpackProgramInfo=void 0;const t=n(6757),r=n(5639),o=n(432),s=n(5614),l={name:"unpack",inputNames:["A"],inputTypes:[r.TextureType.packed]};e.createUnpackProgramInfo=(c,f)=>{const h=f.dims.length,u=(0,s.getChannels)("rc",h),i=u.slice(-2),d=(0,o.getCoordsDataType)(h),p=(0,s.unpackFromChannel)(),_=f.dims.length===0?"":function(b,v){if(b===1)return"rc";let T="";for(let y=0;y<b;y++)T+=v[y],y<b-1&&(T+=",");return T}(h,u),m=h<=1?"rc":`vec2(${i.join(",")})`,g=`
    ${p}
    void main() {
      ${d} rc = getOutputCoords();

       // Sample the texture with the coords to get the rgba channel value.
       vec4 packedInput = getA(${_});

       ${(0,t.getGlsl)(c.session.backend.glContext.version).output} = vec4(getChannel(packedInput, ${m}), 0, 0, 0);
     }
   `;return Object.assign(Object.assign({},l),{hasMain:!0,output:{dims:f.dims,type:f.type,textureType:r.TextureType.unpacked},shaderSource:g})},e.createUnpackProgramInfoLoader=(c,f)=>Object.assign(Object.assign({},l),{get:()=>(0,e.createUnpackProgramInfo)(c,f)})},7862:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseUnsqueezeAttributes=e.unsqueezeV13=e.unsqueeze=void 0;const t=n(7273);e.unsqueeze=(s,l,c)=>{r(l);const f=t.ShapeUtil.unsqueezeShape(l[0].dims,c);return[s.reshapeUnpacked(l[0],f)]},e.unsqueezeV13=(s,l)=>(o(l),(0,e.unsqueeze)(s,[l[0]],Array.from(l[1].integerData))),e.parseUnsqueezeAttributes=s=>s.attributes.getInts("axes");const r=s=>{if(!s||s.length!==1)throw new Error("Unsqueeze requires 1 input.");if(s[0].type==="string")throw new Error("invalid input tensor types.")},o=s=>{if(!s||s.length!==2)throw new Error("Unsqueeze requires 2 inputs.");if(s[1].type!=="int32")throw new Error("Invalid input type.")}},3980:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.scalesValidation=e.validateInputs=e.parseUpsampleAttributes=e.parseUpsampleAttributesV9=e.parseUpsampleAttributesV7=e.upsample=void 0;const t=n(4910),r=n(6757),o=n(5639),s={name:"Upsample",inputNames:["X"],inputTypes:[o.TextureType.unpacked]};e.upsample=(c,f,h)=>((0,e.validateInputs)(f,h),[c.run(Object.assign(Object.assign({},s),{cacheHint:h.cacheKey,get:()=>l(c,f,h)}),f)]),e.parseUpsampleAttributesV7=c=>(0,e.parseUpsampleAttributes)(c,7),e.parseUpsampleAttributesV9=c=>(0,e.parseUpsampleAttributes)(c,9),e.parseUpsampleAttributes=(c,f)=>{const h=f>=10,u=c.attributes.getString("mode","nearest");if(u!=="nearest"&&u!=="linear"&&(f<11||u!=="cubic"))throw new Error(`unrecognized mode: ${u}`);let i=[];f<9&&(i=c.attributes.getFloats("scales"),(0,e.scalesValidation)(i,u,h));const d=c.attributes.getFloat("extrapolation_value",0),p=f>10?c.attributes.getString("coordinate_transformation_mode","half_pixel"):"asymmetric";if(["asymmetric","pytorch_half_pixel","tf_half_pixel_for_nn","align_corners","tf_crop_and_resize","half_pixel"].indexOf(p)===-1)throw new Error(`coordinate_transform_mode '${p}' is not supported`);const _=p==="tf_crop_and_resize",m=_,g=u==="nearest"&&f>=11?c.attributes.getString("nearest_mode","round_prefer_floor"):"";if(["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(g)===-1)throw new Error(`nearest_mode '${g}' is not supported`);const b=c.attributes.getFloat("cubic_coeff_a",-.75),v=c.attributes.getInt("exclude_outside",0)!==0;if(v&&u!=="cubic")throw new Error("exclude_outside can be set to 1 only when mode is CUBIC.");const T=f<11||u==="nearest"&&p==="asymmetric"&&g==="floor";let y=0,w=0,S=0;return f>10?c.inputs.length>2?(y=1,w=2,S=3):(w=1,S=2):f===9&&(w=1),(0,t.createAttributeWithCacheKey)({opset:f,isResize:h,mode:u,scales:i,extrapolationValue:d,coordinateTransformMode:p,useExtrapolation:m,needRoiInput:_,nearestMode:g,cubicCoefficientA:b,excludeOutside:v,useNearest2xOptimization:T,roiInputIdx:y,scalesInputIdx:w,sizesInputIdx:S})};const l=(c,f,h)=>{const u=(0,r.getGlsl)(c.session.backend.glContext.version),[i,d]=c.calculateTextureWidthAndHeight(f[0].dims,o.TextureType.unpacked),p=f[0].dims.map((S,O)=>Math.floor(S*h.scales[O])),[_,m]=c.calculateTextureWidthAndHeight(p,o.TextureType.unpacked),g=p.length,b=new Array(g),v=new Array(g);let T=`
      int output_pitches[${g}];
      int input_pitches[${g}];
      `;for(let S=g-1;S>=0;S--)b[S]=S===g-1?1:b[S+1]*p[S+1],v[S]=S===g-1?1:v[S+1]*f[0].dims[S+1],T+=`
        output_pitches[${S}] = ${b[S]};
        input_pitches[${S}] = ${v[S]};
        `;const y=`
      float getInputFloat(int index) {
        vec2 coords = offsetToCoords(index, ${i}, ${d});
        float value = getColorAsFloat(${u.texture2D}(X, coords));
        return value;
      }
      `,w=h.mode==="nearest"?`
    ${y}
    float process(int indices[${g}]) {
      int input_index = 0;
      int output_index = coordsToOffset(TexCoords, ${_}, ${m});

      ${T}

      int d, m;
      for (int dim = 0; dim < ${g}; ++dim) {
        d = output_index / output_pitches[dim];
        m = output_index - d * output_pitches[dim];
        output_index = m;

        if (scales[dim] != 1 && d > 0) {
          int d2 = d / scales[dim];
          m = d - d2 * scales[dim];
          d = d2;
        }
        input_index += input_pitches[dim] * d;
      }

      return getInputFloat(input_index);
    }`:g===4?`
    ${y}
    float process(int indices[4]) {
      int input_index = 0;
      int output_index = coordsToOffset(TexCoords, ${_}, ${m});

      ${T}

      int m;
      int index_of_dim0, index_of_dim1, index_of_dim2, index_of_dim3;
      index_of_dim0 = output_index / output_pitches[0];
      m = output_index - index_of_dim0 * output_pitches[0];
      index_of_dim1 = m / output_pitches[1];
      m = m - index_of_dim1 * output_pitches[1];
      index_of_dim2 = m / output_pitches[2];
      m = m - index_of_dim2 * output_pitches[2];
      index_of_dim3 = m;

      int index_of_input_dim2, index_of_input_dim3, x_offset, y_offset;
      index_of_input_dim2 = index_of_dim2 / scales[2];
      y_offset = index_of_dim2 - index_of_input_dim2 * scales[2];
      index_of_input_dim3 = index_of_dim3 / scales[3];
      x_offset = index_of_dim3 - index_of_input_dim3 * scales[3];

      input_index = index_of_dim0 * input_pitches[0] +
            index_of_dim1 * input_pitches[1] +
            index_of_input_dim2 * input_pitches[2] +
            index_of_input_dim3;

      float x00 = getInputFloat(input_index);
      float x10, x01, x11;

      bool end_of_dim2 = false;
      if (index_of_input_dim2 == (${f[0].dims[2]} - 1)) {
        // It's the end in dimension 2
        x01 = x00;
        end_of_dim2 = true;
      } else {
        x01 = getInputFloat(input_index + input_pitches[2]);
      }

      if (index_of_input_dim3 == (input_pitches[2] - 1)) {
        // It's the end in dimension 3
        x10 = x00;
        x11 = x01;
      }
      else {
        x10 = getInputFloat(input_index + 1);
        x11 = end_of_dim2 ? x10 : getInputFloat(input_index + input_pitches[2] + 1);
      }

      float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[2]);
      float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[2]);
      return y0 + float(x_offset) * (y1 - y0) / float(scales[3]);
    }`:`
    ${y}
    float process(int indices[2]) {
      int input_index = 0;
      int output_index = coordsToOffset(TexCoords, ${_}, ${m});

      ${T}

      int m;
      int index_of_dim0, index_of_dim1;
      index_of_dim0 = output_index / output_pitches[0];
      m = output_index - index_of_dim0 * output_pitches[0];
      index_of_dim1 = m;

      int index_of_input_dim0, index_of_input_dim1, x_offset, y_offset;
      index_of_input_dim0 = index_of_dim0 / scales[0];
      y_offset = index_of_dim0 - index_of_input_dim0 * scales[0];
      index_of_input_dim1 = index_of_dim1 / scales[1];
      x_offset = index_of_dim1 - index_of_input_dim1 * scales[1];

      input_index = index_of_input_dim0 * input_pitches[0] + index_of_input_dim1;

      float x00 = getInputFloat(input_index);
      float x10, x01, x11;

      bool end_of_dim0 = false;
      if (index_of_input_dim0 == (${f[0].dims[0]} - 1)) {
        // It's the end in dimension 0
        x01 = x00;
        end_of_dim0 = true;
      } else {
        x01 = getInputFloat(input_index + input_pitches[0]);
      }

      if (index_of_input_dim1 == (input_pitches[0] - 1)) {
        // It's the end in dimension 1
        x10 = x00;
        x11 = x01;
      }
      else {
        x10 = getInputFloat(input_index + 1);
        x11 = end_of_dim0 ? x10 : getInputFloat(input_index + input_pitches[0] + 1);
      }

      float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[0]);
      float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[0]);
      return y0 + float(x_offset) * (y1 - y0) / float(scales[1]);
    }`;return Object.assign(Object.assign({},s),{output:{dims:p,type:f[0].type,textureType:o.TextureType.unpacked},shaderSource:w,variables:[{name:"scales",type:"int",arrayLength:h.scales.length,data:h.scales.map(S=>Math.ceil(S))}]})};e.validateInputs=(c,f)=>{if(!c||f.opset<9&&c.length!==1||f.opset>=9&&f.opset<11&&c.length!==2||f.opset>=11&&c.length<2)throw new Error("invalid inputs.");if(f.scales.length>0&&c[0].dims.length!==f.scales.length)throw new Error("Invalid input shape.");if(c[0].type==="string")throw new Error("Invalid input tensor types.")},e.scalesValidation=(c,f,h)=>{if(h){for(const u of c)if(u<=0)throw new Error("Scale value should be greater than 0.")}else for(const u of c)if(u<1)throw new Error("Scale value should be greater than or equal to 1.");if(!(f!=="linear"&&f!=="cubic"||c.length===2||c.length===4&&c[0]===1&&c[1]===1))throw new Error(`'Linear' mode and 'Cubic' mode only support 2-D inputs ('Bilinear', 'Bicubic')         or 4-D inputs with the corresponding outermost 2 scale values being 1         in the ${h?"Resize":"Upsample"} opeartor.`)}},2757:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ProgramManager=void 0;const t=n(2235),r=n(1315),o=n(8897),s=n(6757);e.ProgramManager=class{constructor(l,c,f){this.profiler=l,this.glContext=c,this.textureLayoutStrategy=f,this.repo=new Map,this.attributesBound=!1}getArtifact(l){return this.repo.get(l)}setArtifact(l,c){this.repo.set(l,c)}run(l,c,f){var h;this.profiler.event("op",`ProgramManager.run ${(h=l.programInfo.name)!==null&&h!==void 0?h:"unknown kernel"}`,()=>{var u;const i=this.glContext.gl,d=l.program;i.useProgram(d);try{this.bindOutput(f),this.attributesBound||this.bindAttributes(l.attribLocations),this.bindUniforms(l.uniformLocations,(u=l.programInfo.variables)!==null&&u!==void 0?u:[],c)}catch(p){throw r.Logger.error("ProgramManager",l.programInfo.shaderSource),p}this.profiler.event("backend","GlContext.draw()",()=>{this.glContext.draw()})},this.glContext)}dispose(){this.vertexShader&&this.glContext.deleteShader(this.vertexShader),this.repo.forEach(l=>this.glContext.deleteProgram(l.program))}build(l,c,f){return this.profiler.event("backend","ProgramManager.build",()=>{const h=new o.GlslPreprocessor(this.glContext,l,c,f),u=h.preprocess(),i=this.compile(u);return{programInfo:l,program:i,uniformLocations:this.getUniformLocations(i,h.context.programInfo.inputNames,h.context.programInfo.variables),attribLocations:this.getAttribLocations(i)}})}compile(l){if(!this.vertexShader){r.Logger.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");const h=(0,s.getVertexShaderSource)(this.glContext.version);this.vertexShader=this.glContext.compileShader(h,this.glContext.gl.VERTEX_SHADER)}t.env.debug&&r.Logger.verbose("ProrgramManager",`FragShader:
${l}
`);const c=this.glContext.compileShader(l,this.glContext.gl.FRAGMENT_SHADER),f=this.glContext.createProgram(this.vertexShader,c);return this.glContext.deleteShader(c),f}bindOutput(l){const c=l.width,f=l.height;r.Logger.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${c}/${f}, shape=${l.shape}, type=${l.tensor.type}`),this.glContext.attachFramebuffer(l.texture,c,f)}bindAttributes(l){const c=l.position,f=l.textureCoord;this.glContext.setVertexAttributes(c,f),this.attributesBound=!0}bindUniforms(l,c,f){var h;const u=this.glContext.gl;let i=0;for(const{name:d,type:p,location:_,arrayLength:m}of l){const g=(h=c.find(b=>b.name===d))===null||h===void 0?void 0:h.data;if(p!=="sampler2D"&&!g)throw new Error(`variable '${d}' does not have data defined in program info`);switch(p){case"sampler2D":this.bindTexture(f[i],_,i),i++;break;case"float":m?u.uniform1fv(_,g):u.uniform1f(_,g);break;case"int":m?u.uniform1iv(_,g):u.uniform1i(_,g);break;default:throw new Error(`Uniform not implemented: ${p}`)}}}bindTexture(l,c,f){this.glContext.bindTextureToUniform(l.texture,f,c)}getAttribLocations(l){return{position:this.getAttribLocation(l,"position"),textureCoord:this.getAttribLocation(l,"textureCoord")}}getUniformLocations(l,c,f){const h=[];if(c)for(const u of c)h.push({name:u,type:"sampler2D",location:this.getUniformLocation(l,u)});if(f)for(const u of f)h.push(Object.assign(Object.assign({},u),{location:this.getUniformLocation(l,u.name)}));return h}getUniformLocation(l,c){const f=this.glContext.gl.getUniformLocation(l,c);if(f===null)throw new Error(`Uniform ${c} not found.`);return f}getAttribLocation(l,c){return this.glContext.gl.getAttribLocation(l,c)}}},2171:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLSessionHandler=void 0;const t=n(1315),r=n(5881),o=n(7860),s=n(4110),l=n(2757),c=n(7618),f=n(5243);e.WebGLSessionHandler=class{constructor(h,u){this.backend=h,this.context=u,this.layoutStrategy=new c.PreferLogicalStrategy(h.glContext.maxTextureSize),this.programManager=new l.ProgramManager(this.context.profiler,h.glContext,this.layoutStrategy),this.textureManager=new f.TextureManager(h.glContext,this.layoutStrategy,this.context.profiler,{reuseTextures:h.textureCacheMode==="full"}),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map,this.pack=h.pack,this.pack2unpackMap=new Map,this.unpack2packMap=new Map}createInferenceHandler(){return new o.WebGLInferenceHandler(this)}onGraphInitialized(h){const u=h.getValues().filter(i=>i.from===-1&&i.tensor).map(i=>i.tensor.dataId);this.initializers=new Set(u)}isInitializer(h){return!!this.initializers&&this.initializers.has(h)}addInitializer(h){this.initializers.add(h)}getTextureData(h,u){return u?this.packedTextureDataCache.get(h):this.unpackedTextureDataCache.get(h)}setTextureData(h,u,i=!1){t.Logger.verbose("WebGLSessionHandler","Storing Texture data in cache"),i?this.packedTextureDataCache.set(h,u):this.unpackedTextureDataCache.set(h,u)}dispose(){this.programManager.dispose(),this.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach(h=>this.textureManager.releaseTexture(h,!0)),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach(h=>this.textureManager.releaseTexture(h,!0)),this.unpackedTextureDataCache=new Map}resolve(h,u,i){const d=(0,r.resolveOperator)(h,u,s.WEBGL_OP_RESOLVE_RULES);return{impl:d.opImpl,context:d.opInit?d.opInit(h,i):h}}}},9622:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Uint8DataEncoder=e.RGBAFloatDataEncoder=e.RedFloat32DataEncoder=void 0;const t=n(1315);e.RedFloat32DataEncoder=class{constructor(r,o=1){if(o===1)this.internalFormat=r.R32F,this.format=r.RED,this.textureType=r.FLOAT,this.channelSize=o;else{if(o!==4)throw new Error(`Invalid number of channels: ${o}`);this.internalFormat=r.RGBA32F,this.format=r.RGBA,this.textureType=r.FLOAT,this.channelSize=o}}encode(r,o){let s,l;return r.constructor!==Float32Array&&(t.Logger.warning("Encoder","data was not of type Float32; creating new Float32Array"),l=new Float32Array(r)),o*this.channelSize>r.length?(t.Logger.warning("Encoder","Source data too small. Allocating larger array"),l=r,s=this.allocate(o*this.channelSize),l.forEach((c,f)=>s[f]=c)):(l=r,s=l),s}allocate(r){return new Float32Array(4*r)}decode(r,o){return this.channelSize===1?r.filter((s,l)=>l%4==0).subarray(0,o):r.subarray(0,o)}},e.RGBAFloatDataEncoder=class{constructor(r,o=1,s){if(o!==1&&o!==4)throw new Error(`Invalid number of channels: ${o}`);this.internalFormat=r.RGBA,this.format=r.RGBA,this.channelSize=o,this.textureType=s||r.FLOAT}encode(r,o){let s=r;return this.channelSize===1&&(t.Logger.verbose("Encoder","Exploding into a larger array"),s=this.allocate(o),r.forEach((l,c)=>s[4*c]=l)),s}allocate(r){return new Float32Array(4*r)}decode(r,o){return this.channelSize===1?r.filter((s,l)=>l%4==0).subarray(0,o):r.subarray(0,o)}},e.Uint8DataEncoder=class{constructor(r,o=1){if(this.channelSize=4,o===1)this.internalFormat=r.ALPHA,this.format=r.ALPHA,this.textureType=r.UNSIGNED_BYTE,this.channelSize=o;else{if(o!==4)throw new Error(`Invalid number of channels: ${o}`);this.internalFormat=r.RGBA,this.format=r.RGBA,this.textureType=r.UNSIGNED_BYTE,this.channelSize=o}}encode(r,o){return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}allocate(r){return new Uint8Array(r*this.channelSize)}decode(r,o){if(r instanceof Uint8Array)return r.subarray(0,o);throw new Error(`Invalid array type: ${r.constructor}`)}}},7618:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getBatchDim=e.sizeToSquarishShape=e.getRowsCols=e.sizeFromShape=e.isInt=e.parseAxisParam=e.squeezeShape=e.PreferLogicalStrategy=e.AlwaysKeepOriginalSizeStrategy=void 0;const t=n(1315),r=n(7273);function o(h,u){const i=[],d=[],p=u!=null&&Array.isArray(u)&&u.length===0,_=u==null||p?null:s(u,h).sort();let m=0;for(let g=0;g<h.length;++g){if(_!=null){if(_[m]===g&&h[g]!==1)throw new Error(`Can't squeeze axis ${g} since its dim '${h[g]}' is not 1`);(_[m]==null||_[m]>g)&&h[g]===1&&(i.push(h[g]),d.push(g)),_[m]<=g&&m++}h[g]!==1&&(i.push(h[g]),d.push(g))}return{newShape:i,keptDims:d}}function s(h,u){const i=u.length;return h=h==null?u.map((d,p)=>p):[].concat(h),(0,r.assert)(h.every(d=>d>=-i&&d<i),()=>`All values in axis param must be in range [-${i}, ${i}) but got axis ${h}`),(0,r.assert)(h.every(l),()=>`All values in axis param must be integers but got axis ${h}`),h.map(d=>d<0?i+d:d)}function l(h){return h%1==0}function c(h){if(h.length===0)return 1;let u=h[0];for(let i=1;i<h.length;i++)u*=h[i];return u}function f(h){const u=Math.ceil(Math.sqrt(h));return[u,Math.ceil(h/u)]}e.AlwaysKeepOriginalSizeStrategy=class{constructor(h){this.maxTextureSize=h}computeTextureWH(h,u){if(h.length===0)return[1,1];const i=this.maxTextureSize;if(u&&u.breakAxis!==void 0){const _=u.breakAxis>=h.length?1:h.slice(u.breakAxis).reduce((g,b)=>g*b),m=u.breakAxis<=0?1:h.slice(0,u.breakAxis).reduce((g,b)=>g*b);if(!(_>i||m>i))return[_,m];t.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${h}, breakAxis:${u.breakAxis}`)}const d=h.reduce((_,m)=>_*m);let p=Math.floor(Math.sqrt(d));for(;p<i&&p<d&&d%p!=0;p++);if(p>=i||d%p!=0)throw new Error(`The given dimensions are outside this GPU's boundaries: ${h}`);return[p,d/p]}},e.PreferLogicalStrategy=class{constructor(h){this.maxTextureSize=h}computeTextureWH(h,u){const i=this.computeTexture(h,u);return u&&u.isPacked&&(i[0]/=2,i[1]/=2),u&&u.reverseWH?[i[1],i[0]]:i}computeTexture(h,u){const i=u&&u.isPacked;if(h.length===0)return i?[2,2]:[1,1];let d=this.maxTextureSize;if(u&&u.breakAxis!==void 0){const m=u.breakAxis>=h.length?1:h.slice(u.breakAxis).reduce((b,v)=>b*v),g=u.breakAxis<=0?1:h.slice(0,u.breakAxis).reduce((b,v)=>b*v);if(!(m>d||g>d))return[m,g];t.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${h}, breakAxis:${u.breakAxis}`)}let p=h.slice(0);i&&(d*=2,p=p.map((m,g)=>g>=p.length-2?p[g]%2==0?p[g]:p[g]+1:p[g]),p.length===1&&(p=[2,p[0]])),p.length!==2&&(p=o(p).newShape);const _=c(p);return p.length<=1&&_<=d?[1,_]:p.length===2&&p[0]<=d&&p[1]<=d?p:p.length===3&&p[0]*p[1]<=d&&p[2]<=d?[p[0]*p[1],p[2]]:p.length===3&&p[0]<=d&&p[1]*p[2]<=d?[p[0],p[1]*p[2]]:p.length===4&&p[0]*p[1]*p[2]<=d&&p[3]<=d?[p[0]*p[1]*p[2],p[3]]:p.length===4&&p[0]<=d&&p[1]*p[2]*p[3]<=d?[p[0],p[1]*p[2]*p[3]]:i?f(_/4).map(m=>2*m):f(_)}},e.squeezeShape=o,e.parseAxisParam=s,e.isInt=l,e.sizeFromShape=c,e.getRowsCols=function(h){if(h.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[h.length>1?h[h.length-2]:1,h[h.length-1]]},e.sizeToSquarishShape=f,e.getBatchDim=function(h,u=2){return c(h.slice(0,h.length-u))}},3314:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createTextureLayoutFromShape=e.calculateTextureWidthAndHeight=e.createTextureLayoutFromTextureType=void 0;const t=n(7273),r=n(5639);e.createTextureLayoutFromTextureType=(o,s,l)=>{const c=l===r.TextureType.unpacked||l===r.TextureType.unpackedReversed?1:4,f=l===r.TextureType.packed,h=l===r.TextureType.unpackedReversed||l===r.TextureType.packed,u=l===r.TextureType.packedLastDimension?s.length-1:void 0,i=l===r.TextureType.packedLastDimension?s.map((d,p)=>p===s.length-1?4*d:d):void 0;return(0,e.createTextureLayoutFromShape)(o,s,c,i,{isPacked:f,reverseWH:h,breakAxis:u})},e.calculateTextureWidthAndHeight=(o,s,l)=>{const c=(0,e.createTextureLayoutFromTextureType)(o,s,l);return[c.width,c.height]},e.createTextureLayoutFromShape=(o,s,l=1,c,f)=>{const h=!(!f||!f.isPacked),[u,i]=o.computeTextureWH(h&&c||s,f),d=s.length;let p=s.slice(0);if(d===0&&(p=[1]),l===1)c=s;else if(h){if(l!==4)throw new Error("a packed texture must be 4-channel");c=s,d>0&&(p[d-1]=Math.ceil(p[d-1]/2)),d>1&&(p[d-2]=Math.ceil(p[d-2]/2))}else if(!c)throw new Error("Unpacked shape is needed when using channels > 1");return{width:u,height:i,channels:l,isPacked:h,shape:p,strides:t.ShapeUtil.computeStrides(p),unpackedShape:c,reversedWH:f&&f.reverseWH}}},5243:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TextureManager=void 0;const t=n(1315);e.TextureManager=class{constructor(r,o,s,l){this.glContext=r,this.layoutStrategy=o,this.profiler=s,this.config=l,this.pendingRead=new Map,l.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(r,o,s,l){const c=this.toEncoderType(r),f=this.glContext.getEncoder(c,o.channels||1,l);if(o.isPacked&&l===1)throw new Error("not implemented");const h=o.width,u=o.height;let i,d;if(this.config.reuseTextures){i=`${h}x${u}_${f.format}_${f.internalFormat}_${f.textureType}`,d=this.inUseTextures.get(i),d||(d=[],this.inUseTextures.set(i,d));const _=this.idleTextures.get(i);if(_&&_.length>0){const m=_.pop();return d.push(m),l===1&&this.glContext.updateTexture(m,h,u,f,this.toTextureData(r,s)),m}}t.Logger.verbose("TextureManager",`Creating new texture of size ${o.width}x${o.height}`);const p=this.glContext.allocateTexture(h,u,f,this.toTextureData(r,s));return this.config.reuseTextures&&(d.push(p),this.textureLookup.set(p,i)),p}readTexture(r,o,s){return s||(s=1),this.profiler.event("backend","TextureManager.readTexture",()=>{const l=r.shape.reduce((f,h)=>f*h)*s,c=this.glContext.readTexture(r.texture,r.width,r.height,l,this.toEncoderType(o),s);return this.toTensorData(o,c)})}async readTextureAsync(r,o,s){const l=r.tensor.dataId;if(s||(s=1),this.pendingRead.has(l)){const c=this.pendingRead.get(l);return new Promise(f=>c==null?void 0:c.push(f))}return this.profiler.event("backend","TextureManager.readTextureAsync",async()=>{this.pendingRead.set(l,[]);const c=r.shape.reduce((i,d)=>i*d)*s;await this.glContext.createAndWaitForFence();const f=this.glContext.readTexture(r.texture,r.width,r.height,c,this.toEncoderType(o),s),h=this.toTensorData(o,f),u=this.pendingRead.get(l);return this.pendingRead.delete(l),u==null||u.forEach(i=>i(h)),h})}readUint8TextureAsFloat(r){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",()=>{const o=r.shape.reduce((l,c)=>l*c),s=this.glContext.readTexture(r.texture,r.width,r.height,4*o,"byte",4);return new Float32Array(s.buffer,s.byteOffset,o)})}releaseTexture(r,o){let s;if(this.config.reuseTextures&&(s=this.textureLookup.get(r.texture),s)){o&&this.textureLookup.delete(s);const l=this.inUseTextures.get(s);if(l){const c=l.indexOf(r.texture);if(c!==-1){l.splice(c,1);let f=this.idleTextures.get(s);f||(f=[],this.idleTextures.set(s,f)),f.push(r.texture)}}}s&&!o||(t.Logger.verbose("TextureManager",`Deleting texture of size ${r.width}x${r.height}`),this.glContext.deleteTexture(r.texture))}toTensorData(r,o){switch(r){case"int16":return o instanceof Int16Array?o:Int16Array.from(o);case"int32":return o instanceof Int32Array?o:Int32Array.from(o);case"int8":return o instanceof Int8Array?o:Int8Array.from(o);case"uint16":return o instanceof Uint16Array?o:Uint16Array.from(o);case"uint32":return o instanceof Uint32Array?o:Uint32Array.from(o);case"uint8":case"bool":return o instanceof Uint8Array?o:Uint8Array.from(o);case"float32":return o instanceof Float32Array?o:Float32Array.from(o);case"float64":return o instanceof Float64Array?o:Float64Array.from(o);default:throw new Error(`TensorData type ${r} is not supported`)}}toTextureData(r,o){if(o)return o instanceof Float32Array?o:new Float32Array(o)}toEncoderType(r){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}},5639:(a,e)=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.TextureType=void 0,(n=e.TextureType||(e.TextureType={}))[n.unpacked=0]="unpacked",n[n.unpackedReversed=1]="unpackedReversed",n[n.packed=2]="packed",n[n.downloadUint8AsFloat=3]="downloadUint8AsFloat",n[n.packedLastDimension=4]="packedLastDimension"},432:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getGlChannels=e.getCoordsDataType=e.getSqueezedParams=e.squeezeInputShape=e.generateShaderFuncNameFromInputSamplerNameAtOutCoords=e.generateShaderFuncNameFromInputSamplerName=e.repeatedTry=e.getPackedShape=void 0;const t=n(7273);e.getPackedShape=function(r){const o=r.length;return r.slice(0,o-1).concat(r[o-1]/4)},e.repeatedTry=async function(r,o=l=>0,s){return new Promise((l,c)=>{let f=0;const h=()=>{if(r())return void l();f++;const u=o(f);s!=null&&f>=s?c():setTimeout(h,u)};h()})},e.generateShaderFuncNameFromInputSamplerName=function(r){return(0,t.assert)(r!==void 0&&r.length!==0,()=>"empty string found for sampler name"),"get"+r.charAt(0).toUpperCase()+r.slice(1)},e.generateShaderFuncNameFromInputSamplerNameAtOutCoords=function(r){return(0,t.assert)(r!==void 0&&r.length!==0,()=>"empty string found for sampler name"),"get"+r.charAt(0).toUpperCase()+r.slice(1)+"AtOutCoords"},e.squeezeInputShape=function(r,o){let s=JSON.parse(JSON.stringify(r));return s=o,s},e.getSqueezedParams=function(r,o){return o.map(s=>r[s]).join(", ")},e.getCoordsDataType=function(r){if(r<=1)return"int";if(r===2)return"ivec2";if(r===3)return"ivec3";if(r===4)return"ivec4";if(r===5)return"ivec5";if(r===6)return"ivec6";throw Error(`GPU for rank ${r} is not yet supported`)},e.getGlChannels=function(r=6){return["x","y","z","w","u","v"].slice(0,r)}},3389:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createNewWebGLContext=e.createWebGLContext=void 0;const t=n(1315),r=n(3524),o={};function s(l,c){let f;const h={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1};if((!c||c==="webgl2")&&(f=l.getContext("webgl2",h),f))try{return new r.WebGLContext(f,2)}catch(u){t.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${u}`)}if((!c||c==="webgl")&&(f=l.getContext("webgl",h)||l.getContext("experimental-webgl",h),f))try{return new r.WebGLContext(f,1)}catch(u){t.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${u}`)}throw new Error("WebGL is not supported")}e.createWebGLContext=function l(c){let f;if(c&&c!=="webgl2"||!("webgl2"in o)?c&&c!=="webgl"||!("webgl"in o)||(f=o.webgl):f=o.webgl2,!f)try{f=s(function(){if(typeof OffscreenCanvas>"u")throw new TypeError("failed to create offscreen canvas: OffscreenCanvas is not supported");return new OffscreenCanvas(1,1)}(),c)}catch{f=s(function(){if(typeof document>"u")throw new TypeError("failed to create canvas: document is not supported");const i=document.createElement("canvas");return i.width=1,i.height=1,i}(),c)}c=c||f.version===1?"webgl":"webgl2";const h=f.gl;return o[c]=f,h.isContextLost()?(delete o[c],l(c)):(h.disable(h.DEPTH_TEST),h.disable(h.STENCIL_TEST),h.disable(h.BLEND),h.disable(h.DITHER),h.disable(h.POLYGON_OFFSET_FILL),h.disable(h.SAMPLE_COVERAGE),h.enable(h.SCISSOR_TEST),h.enable(h.CULL_FACE),h.cullFace(h.BACK),f)},e.createNewWebGLContext=s},3524:function(a,e,n){var t=this&&this.__createBinding||(Object.create?function(h,u,i,d){d===void 0&&(d=i);var p=Object.getOwnPropertyDescriptor(u,i);p&&!("get"in p?!u.__esModule:p.writable||p.configurable)||(p={enumerable:!0,get:function(){return u[i]}}),Object.defineProperty(h,d,p)}:function(h,u,i,d){d===void 0&&(d=i),h[d]=u[i]}),r=this&&this.__setModuleDefault||(Object.create?function(h,u){Object.defineProperty(h,"default",{enumerable:!0,value:u})}:function(h,u){h.default=u}),o=this&&this.__importStar||function(h){if(h&&h.__esModule)return h;var u={};if(h!=null)for(var i in h)i!=="default"&&Object.prototype.hasOwnProperty.call(h,i)&&t(u,h,i);return r(u,h),u};Object.defineProperty(e,"__esModule",{value:!0}),e.WebGLContext=e.linearSearchLastTrue=void 0;const s=n(2235),l=o(n(9622)),c=n(432);function f(h){let u=0;for(;u<h.length&&h[u]();++u);return u-1}e.linearSearchLastTrue=f,e.WebGLContext=class{constructor(h,u){this.frameBufferBound=!1,this.itemsToPoll=[],this.gl=h,this.version=u,this.getExtensions(),this.vertexbuffer=this.createVertexbuffer(),this.framebuffer=this.createFramebuffer(),this.queryVitalParameters()}allocateTexture(h,u,i,d){const p=this.gl,_=p.createTexture();p.bindTexture(p.TEXTURE_2D,_),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE);const m=d?i.encode(d,h*u):null;return p.texImage2D(p.TEXTURE_2D,0,i.internalFormat,h,u,0,i.format,i.textureType,m),this.checkError(),_}updateTexture(h,u,i,d,p){const _=this.gl;_.bindTexture(_.TEXTURE_2D,h);const m=d.encode(p,u*i);_.texSubImage2D(_.TEXTURE_2D,0,0,0,u,i,d.format,d.textureType,m),this.checkError()}attachFramebuffer(h,u,i){const d=this.gl;d.bindTexture(d.TEXTURE_2D,h),d.bindFramebuffer(d.FRAMEBUFFER,this.framebuffer),d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,h,0),this.checkError(),d.viewport(0,0,u,i),d.scissor(0,0,u,i)}readTexture(h,u,i,d,p,_){const m=this.gl;_||(_=1),this.frameBufferBound||this.attachFramebuffer(h,u,i);const g=this.getEncoder(p,_),b=g.allocate(u*i);return m.bindTexture(m.TEXTURE_2D,h),m.framebufferTexture2D(m.FRAMEBUFFER,m.COLOR_ATTACHMENT0,m.TEXTURE_2D,h,0),m.readPixels(0,0,u,i,m.RGBA,g.textureType,b),this.checkError(),g.decode(b,d)}isFramebufferReady(){return!0}getActiveTexture(){const h=this.gl;return"TEXTURE"+(h.getParameter(this.gl.ACTIVE_TEXTURE)-h.TEXTURE0)}getTextureBinding(){return this.gl.getParameter(this.gl.TEXTURE_BINDING_2D)}getFramebufferBinding(){return this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING)}setVertexAttributes(h,u){const i=this.gl;i.vertexAttribPointer(h,3,i.FLOAT,!1,20,0),i.enableVertexAttribArray(h),u!==-1&&(i.vertexAttribPointer(u,2,i.FLOAT,!1,20,12),i.enableVertexAttribArray(u)),this.checkError()}createProgram(h,u){const i=this.gl,d=i.createProgram();return i.attachShader(d,h),i.attachShader(d,u),i.linkProgram(d),d}compileShader(h,u){const i=this.gl,d=i.createShader(u);if(!d)throw new Error(`createShader() returned null with type ${u}`);if(i.shaderSource(d,h),i.compileShader(d),i.getShaderParameter(d,i.COMPILE_STATUS)===!1)throw new Error(`Failed to compile shader: ${i.getShaderInfoLog(d)}
Shader source:
${h}`);return d}deleteShader(h){this.gl.deleteShader(h)}bindTextureToUniform(h,u,i){const d=this.gl;d.activeTexture(d.TEXTURE0+u),this.checkError(),d.bindTexture(d.TEXTURE_2D,h),this.checkError(),d.uniform1i(i,u),this.checkError()}draw(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.checkError()}checkError(){if(s.env.debug){const h=this.gl,u=h.getError();let i="";switch(u){case h.NO_ERROR:return;case h.INVALID_ENUM:i="INVALID_ENUM";break;case h.INVALID_VALUE:i="INVALID_VALUE";break;case h.INVALID_OPERATION:i="INVALID_OPERATION";break;case h.INVALID_FRAMEBUFFER_OPERATION:i="INVALID_FRAMEBUFFER_OPERATION";break;case h.OUT_OF_MEMORY:i="OUT_OF_MEMORY";break;case h.CONTEXT_LOST_WEBGL:i="CONTEXT_LOST_WEBGL";break;default:i=`Unknown WebGL Error: ${u.toString(16)}`}throw new Error(i)}}deleteTexture(h){this.gl.deleteTexture(h)}deleteProgram(h){this.gl.deleteProgram(h)}getEncoder(h,u,i=0){if(this.version===2)return new l.RedFloat32DataEncoder(this.gl,u);switch(h){case"float":return i===1||this.isRenderFloat32Supported?new l.RGBAFloatDataEncoder(this.gl,u):new l.RGBAFloatDataEncoder(this.gl,u,this.textureHalfFloatExtension.HALF_FLOAT_OES);case"int":throw new Error("not implemented");case"byte":return new l.Uint8DataEncoder(this.gl,u);default:throw new Error(`Invalid dataType: ${h}`)}}clearActiveTextures(){const h=this.gl;for(let u=0;u<this.maxTextureImageUnits;++u)h.activeTexture(h.TEXTURE0+u),h.bindTexture(h.TEXTURE_2D,null)}dispose(){if(this.disposed)return;const h=this.gl;h.bindFramebuffer(h.FRAMEBUFFER,null),h.deleteFramebuffer(this.framebuffer),h.bindBuffer(h.ARRAY_BUFFER,null),h.deleteBuffer(this.vertexbuffer),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,null),h.finish(),this.disposed=!0}createDefaultGeometry(){return new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0])}createVertexbuffer(){const h=this.gl,u=h.createBuffer();if(!u)throw new Error("createBuffer() returned null");const i=this.createDefaultGeometry();return h.bindBuffer(h.ARRAY_BUFFER,u),h.bufferData(h.ARRAY_BUFFER,i,h.STATIC_DRAW),this.checkError(),u}createFramebuffer(){const h=this.gl.createFramebuffer();if(!h)throw new Error("createFramebuffer returned null");return h}queryVitalParameters(){const h=this.gl;if(this.isFloatTextureAttachableToFrameBuffer=this.checkFloatTextureAttachableToFrameBuffer(),this.isRenderFloat32Supported=this.checkRenderFloat32(),this.isFloat32DownloadSupported=this.checkFloat32Download(),this.version===1&&!this.textureHalfFloatExtension&&!this.isRenderFloat32Supported)throw new Error("both float32 and float16 TextureType are not supported");this.isBlendSupported=!this.isRenderFloat32Supported||this.checkFloat32Blend(),this.maxTextureSize=h.getParameter(h.MAX_TEXTURE_SIZE),this.maxTextureImageUnits=h.getParameter(h.MAX_TEXTURE_IMAGE_UNITS),this.version}getExtensions(){this.version===2?(this.colorBufferFloatExtension=this.gl.getExtension("EXT_color_buffer_float"),this.disjointTimerQueryWebgl2Extension=this.gl.getExtension("EXT_disjoint_timer_query_webgl2")):(this.textureFloatExtension=this.gl.getExtension("OES_texture_float"),this.textureHalfFloatExtension=this.gl.getExtension("OES_texture_half_float"))}checkFloatTextureAttachableToFrameBuffer(){const h=this.gl,u=h.createTexture();h.bindTexture(h.TEXTURE_2D,u);const i=this.version===2?h.RGBA32F:h.RGBA;h.texImage2D(h.TEXTURE_2D,0,i,1,1,0,h.RGBA,h.FLOAT,null);const d=h.createFramebuffer();h.bindFramebuffer(h.FRAMEBUFFER,d),h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,u,0);const p=h.checkFramebufferStatus(h.FRAMEBUFFER)===h.FRAMEBUFFER_COMPLETE;return h.bindTexture(h.TEXTURE_2D,null),h.bindFramebuffer(h.FRAMEBUFFER,null),h.deleteTexture(u),h.deleteFramebuffer(d),p}checkRenderFloat32(){if(this.version===2){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension)return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Download(){if(this.version===2){if(!this.colorBufferFloatExtension)return!1}else if(!this.textureFloatExtension||!this.gl.getExtension("WEBGL_color_buffer_float"))return!1;return this.isFloatTextureAttachableToFrameBuffer}checkFloat32Blend(){const h=this.gl;let u,i,d,p,_;try{u=h.createTexture(),i=h.createFramebuffer(),h.bindTexture(h.TEXTURE_2D,u);const m=this.version===2?h.RGBA32F:h.RGBA;return h.texImage2D(h.TEXTURE_2D,0,m,1,1,0,h.RGBA,h.FLOAT,null),h.bindFramebuffer(h.FRAMEBUFFER,i),h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,u,0),h.enable(h.BLEND),d=h.createShader(h.VERTEX_SHADER),!!d&&(h.shaderSource(d,"void main(){}"),h.compileShader(d),p=h.createShader(h.FRAGMENT_SHADER),!!p&&(h.shaderSource(p,"precision highp float;void main(){gl_FragColor=vec4(0.5);}"),h.compileShader(p),_=h.createProgram(),!!_&&(h.attachShader(_,d),h.attachShader(_,p),h.linkProgram(_),h.useProgram(_),h.drawArrays(h.POINTS,0,1),h.getError()===h.NO_ERROR)))}finally{h.disable(h.BLEND),_&&h.deleteProgram(_),d&&h.deleteShader(d),p&&h.deleteShader(p),i&&(h.bindFramebuffer(h.FRAMEBUFFER,null),h.deleteFramebuffer(i)),u&&(h.bindTexture(h.TEXTURE_2D,null),h.deleteTexture(u))}}beginTimer(){if(this.version===2&&this.disjointTimerQueryWebgl2Extension){const h=this.gl,u=this.disjointTimerQueryWebgl2Extension,i=h.createQuery();return h.beginQuery(u.TIME_ELAPSED_EXT,i),i}throw new Error("WebGL1 profiling currently not supported.")}endTimer(){if(this.version!==2||!this.disjointTimerQueryWebgl2Extension)throw new Error("WebGL1 profiling currently not supported");{const h=this.gl,u=this.disjointTimerQueryWebgl2Extension;h.endQuery(u.TIME_ELAPSED_EXT)}}isTimerResultAvailable(h){let u=!1,i=!1;if(this.version!==2||!this.disjointTimerQueryWebgl2Extension)throw new Error("WebGL1 profiling currently not supported");{const d=this.gl,p=this.disjointTimerQueryWebgl2Extension;u=d.getQueryParameter(h,d.QUERY_RESULT_AVAILABLE),i=d.getParameter(p.GPU_DISJOINT_EXT)}return u&&!i}getTimerResult(h){let u=0;if(this.version!==2)throw new Error("WebGL1 profiling currently not supported");{const i=this.gl;u=i.getQueryParameter(h,i.QUERY_RESULT),i.deleteQuery(h)}return u/1e6}async waitForQueryAndGetTime(h){return await(0,c.repeatedTry)(()=>this.isTimerResultAvailable(h)),this.getTimerResult(h)}async createAndWaitForFence(){const h=this.createFence(this.gl);return this.pollFence(h)}createFence(h){let u;const i=h,d=i.fenceSync(i.SYNC_GPU_COMMANDS_COMPLETE,0);return h.flush(),u=d===null?()=>!0:()=>{const p=i.clientWaitSync(d,0,0);return p===i.ALREADY_SIGNALED||p===i.CONDITION_SATISFIED},{query:d,isFencePassed:u}}async pollFence(h){return new Promise(u=>{this.addItemToPoll(()=>h.isFencePassed(),()=>u())})}pollItems(){const h=f(this.itemsToPoll.map(u=>u.isDoneFn));for(let u=0;u<=h;++u){const{resolveFn:i}=this.itemsToPoll[u];i()}this.itemsToPoll=this.itemsToPoll.slice(h+1)}async addItemToPoll(h,u){this.itemsToPoll.push({isDoneFn:h,resolveFn:u}),this.itemsToPoll.length>1||await(0,c.repeatedTry)(()=>(this.pollItems(),this.itemsToPoll.length===0))}}},6496:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ExecutionPlan=void 0;const t=n(1315);class r{constructor(s,l){this.op=s,this.node=l}}e.ExecutionPlan=class{constructor(o,s,l){this.graph=o,this.profiler=l,this.initialize(s)}initialize(o){this.profiler.event("session","ExecutionPlan.initialize",()=>{const s=this.graph.getNodes();if(s.length!==o.length)throw new Error("The size of nodes and OPs do not match.");this._ops=o.map((l,c)=>new r(l,s[c])),this.reset(),this._starter=[],this._ops.forEach((l,c)=>{let f=!0;for(const h of l.node.inputs)if(!this._values[h]&&this.graph.getInputIndices().indexOf(h)===-1){f=!1;break}f&&this._starter.push(c)})})}reset(){this._values=this.graph.getValues().map(o=>o.tensor)}async execute(o,s){return this.profiler.event("session","ExecutionPlan.execute",async()=>{this.reset();const l=o.createInferenceHandler(),c=this.graph.getInputIndices();if(s.length!==c.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${s.length} expected: ${c.length}`);s.forEach((p,_)=>{const m=c[_];this._values[m]=p});const f=this._starter.slice(0),h=this.graph.getValues(),u=this.graph.getNodes();let i=0;for(;i<f.length;){const p=f[i++],_=this._ops[p],m=_.node.inputs.map(T=>this._values[T]);if(m.indexOf(void 0)!==-1)throw new Error(`unresolved input detected: op: ${_.node}`);const g=m;t.Logger.verbose("ExecPlan",`Runing op:${_.node.name} (${g.map((T,y)=>`'${_.node.inputs[y]}': ${T.type}[${T.dims.join(",")}]`).join(", ")})`);const b=await this.profiler.event("node",_.node.name,async()=>_.op.impl(l,g,_.op.context));if(b.length!==_.node.outputs.length)throw new Error("the size of output does not match model definition.");b.forEach((T,y)=>{const w=_.node.outputs[y];if(this._values[w])throw new Error(`output [${w}] already has value: op:${_.node.name}`);this._values[w]=T});const v=new Set;b.forEach((T,y)=>{const w=_.node.outputs[y];for(const S of h[w].to){const O=u[S];let P=!0;for(const E of O.inputs)if(!this._values[E]){P=!1;break}P&&v.add(S)}}),f.push(...v)}const d=[];for(let p=0;p<this.graph.getOutputIndices().length;p++){const _=this.graph.getOutputIndices()[p],m=this._values[_];if(m===void 0)throw new Error(`required output [${_}] does not have value`);_===0?await m.getData():m.data,d.push(m)}return t.Logger.verbose("ExecPlan","disposing of inferenceHandler"),l.dispose(),d})}}},4662:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Graph=void 0;const t=n(6874),r=n(5127),o=n(2446),s=n(9240),l=n(7273);var c=r.onnxruntime.experimental.fbs;e.Graph={from:(i,d)=>new u(i,d)};class f{constructor(d){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,d&&(this.type=l.ProtoUtil.tensorValueTypeFromProto(d.type.tensorType))}get from(){return this._from}get to(){return this._to}}class h{constructor(d,p){d instanceof o.onnx.NodeProto?(this.name=d.name,this.opType=d.opType,this.attributes=new t.Attribute(d.attribute)):d instanceof c.Node&&(this.name=p??d.name(),this.opType=d.opType(),this.attributes=new t.Attribute(l.ProtoUtil.tensorAttributesFromORTFormat(d))),this.inputs=[],this.outputs=[],this.executeNode=!0}}class u{constructor(d,p){if(!d)throw new TypeError("graph is empty");this.buildGraph(d),this.transformGraph(p),this.checkIsAcyclic()}getInputIndices(){return this._allInputIndices}getInputNames(){return this._allInputNames}getOutputIndices(){return this._allOutputIndices}getOutputNames(){return this._allOutputNames}getValues(){return this._allData}getNodes(){return this._nodes}buildGraph(d){if(d instanceof o.onnx.GraphProto)this.buildGraphFromOnnxFormat(d);else{if(!(d instanceof c.Graph))throw new TypeError("Graph type is not supported.");this.buildGraphFromOrtFormat(d)}}buildGraphFromOnnxFormat(d){const p=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];const _=new Map;if(!d.input)throw new Error("missing information in graph: input");const m=[];for(const g of d.input){if(p.has(g.name))throw new Error(`duplicated input name: ${g.name}`);const b=this._allData.push(new f(g))-1;p.set(g.name,b),m.push(g.name)}if(!d.initializer)throw new Error("missing information in graph: initializer");for(const g of d.initializer){let b=p.get(g.name);if(b===void 0){const v=new f;v.type={shape:{dims:l.ProtoUtil.tensorDimsFromProto(g.dims)},tensorType:l.ProtoUtil.tensorDataTypeFromProto(g.dataType)},b=this._allData.push(v)-1,p.set(g.name,b)}this._allData[b]._from=-1,this._allData[b].tensor=s.Tensor.fromProto(g)}for(let g=0;g<this._allData.length;g++)this._allData[g].tensor||(this._allInputIndices.push(g),this._allInputNames.push(m[g]));if(!d.output)throw new Error("missing information in graph: output");for(const g of d.output){if(p.has(g.name))throw new Error(`duplicated output name: ${g.name}`);const b=this._allData.push(new f(g))-1;p.set(g.name,b),this._allOutputIndices.push(b),this._allOutputNames.push(g.name)}if(!d.node)throw new Error("missing information in graph: node");for(const g of d.node){if(!g.name)for(let v=0;;v++){const T=`unnamed_${g.opType}_${v}`;if(!_.has(T)){g.name=T;break}}if(_.has(g.name))throw new Error(`duplicated node name: ${g.name}`);const b=this._nodes.push(new h(g))-1;_.set(g.name,b)}for(let g=0;g<this._nodes.length;g++){const b=this._nodes[g],v=d.node[g];if(!v.output)throw new Error(`missing output for node: ${v.name}`);for(const T of v.output){let y=p.get(T);if(y===void 0&&(y=this._allData.push(new f)-1,p.set(T,y)),b.outputs.push(y),this._allData[y]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${y}`);if(this._allData[y]._from=g,v.opType==="Constant"){if(!v.attribute||v.attribute.length!==1||!v.attribute[0].t)throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(!v.output||v.output.length!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");b.outputs.pop(),b.executeNode=!1,this._allData[y]._from=-1,this._allData[y].tensor=s.Tensor.fromProto(v.attribute[0].t)}}}for(let g=0;g<this._nodes.length;g++){const b=this._nodes[g],v=d.node[g];if(!v.input)throw new Error(`missing input for node: ${v.name}`);for(const T of v.input){const y=p.get(T);if(y===void 0){if(T===""&&(v.input.length===3||v.input.length===4)&&v.opType==="Resize")continue;throw new Error(`unrecognized input '${T}' for node: ${v.name}`)}b.inputs.push(y),this._allData[y]._to.push(g)}}return!0}buildGraphFromOrtFormat(d){var p,_,m;const g=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];const b=new Map,v=[];for(let T=0;T<d.inputsLength();T++){const y=d.inputs(T);if(g.has(y))throw new Error(`duplicated input name: ${y}`);for(let w=0;w<d.nodeArgsLength();w++)if(((p=d.nodeArgs(w))===null||p===void 0?void 0:p.name())===y){const S=new f;if(((m=(_=d.nodeArgs(w))===null||_===void 0?void 0:_.type())===null||m===void 0?void 0:m.valueType())!==c.TypeInfoValue.tensor_type)throw new Error("Unexpected value type for the nodeArg.");const O=d.nodeArgs(w).type().value(new c.TensorTypeAndShape),P=l.ProtoUtil.tensorDataTypeFromProto(O.elemType()),E=O.shape(),A=[];for(let k=0;k<E.dimLength();k++)A.push(l.LongUtil.longToNumber(E.dim(k).value().dimValue()));S.type={shape:{dims:A},tensorType:P};const $=this._allData.push(S)-1;g.set(y,$),v.push(y)}}for(let T=0;T<d.initializersLength();T++){const y=d.initializers(T);let w=g.get(y.name());if(w===void 0){const S=new f,O=l.ProtoUtil.tensorDimsFromORTFormat(y),P=l.ProtoUtil.tensorDataTypeFromProto(y.dataType());S.type={shape:{dims:O},tensorType:P},w=this._allData.push(S)-1,g.set(y.name(),w)}this._allData[w]._from=-1,this._allData[w].tensor=s.Tensor.fromOrtTensor(y)}for(let T=0;T<this._allData.length;T++)this._allData[T].tensor||(this._allInputIndices.push(T),this._allInputNames.push(v[T]));for(let T=0;T<d.outputsLength();T++){const y=d.outputs(T);if(g.has(y))throw new Error(`duplicated output name: ${y}`);const w=this._allData.push(new f)-1;g.set(y,w),this._allOutputIndices.push(w),this._allOutputNames.push(y)}if(!d.nodes)throw new Error("missing information in graph: node");for(let T=0;T<d.nodesLength();T++){const y=d.nodes(T);let w=y.name();if(!w)for(let O=0;w=`unnamed_${y.opType()}_${O}`,b.has(w);O++);if(b.has(w))throw new Error(`duplicated node name: ${w}`);const S=this._nodes.push(new h(y,w))-1;b.set(w,S)}for(let T=0;T<this._nodes.length;T++){const y=this._nodes[T],w=d.nodes(T);if(w==null)throw new Error(`No node exists at index ${T}`);if((w==null?void 0:w.outputsLength())===0)throw new Error(`missing output for node: ${w.name}`);for(let S=0;S<(w==null?void 0:w.outputsLength());S++){const O=w==null?void 0:w.outputs(S);let P=g.get(O);if(P===void 0&&(P=this._allData.push(new f)-1,g.set(O,P)),y.outputs.push(P),this._allData[P]._from!==void 0)throw new Error(`multiple nodes output to one data value: ${P}`);if(this._allData[P]._from=T,w.opType()==="Constant"){if(w.attributesLength()!==1||!w.attributes(0).t())throw new Error("missing attributes or missing tensor value in attributes for this Constant operator");if(w.outputsLength()!==1)throw new Error("missing output or incorrect number of outputs for this Constant operator");y.outputs.pop(),y.executeNode=!1,this._allData[P]._from=-1,this._allData[P].tensor=s.Tensor.fromOrtTensor(w.attributes(0).t())}}}for(let T=0;T<this._nodes.length;T++){const y=this._nodes[T],w=d.nodes(T);if(w.inputsLength()===0)throw new Error(`missing input for node: ${w.name}`);for(let S=0;S<w.inputsLength();S++){const O=w.inputs(S),P=g.get(O);if(P===void 0)throw new Error(`unrecognized input '${O}' for node: ${w.name()}`);y.inputs.push(P),this._allData[P]._to.push(T)}}}checkIsAcyclic(){const d=new Set;this._allInputIndices.forEach(m=>{this._allData[m]._to.forEach(g=>{d.add(g)})});const p=Array.from(d),_=new Array(this._nodes.length).fill("white");for(;p.length>0;){const m=p.pop();_[m]==="gray"?_[m]="black":(p.push(m),_[m]="gray",this._nodes[m].outputs.forEach(g=>{const b=this._allData[g];if(b.tensor!==void 0)throw new Error("node outputs should not be initialized");if(b._from!==m)throw new Error("from property of the Value object doesn't match index of Node being processed");b._to.forEach(v=>{if(_[v]==="gray")throw new Error("model graph is cyclic");_[v]==="white"&&p.push(v)})}))}}transformGraph(d){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),d&&d.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let d=0;const p=new Array(this._nodes.length,0);let _=0;for(let m=0;m<this._nodes.length;m++)p[m]=_,this._nodes[m].executeNode?(_!==m&&(this._nodes[_]=this._nodes[m]),_++):this._nodes[m].outputs.forEach(g=>{this._allData[g]._from=-2});this._nodes.splice(_,this._nodes.length-_);for(let m=0;m<this._allData.length;m++){const g=this._allData[m];g._from!==void 0&&g._from!==-1&&g._from!==-2&&(g._from=p[g._from]);for(let b=0;b<g._to.length;b++){if(!(g._to[b]>=0))throw new Error("Trying to update a removed node");g._to[b]=p[g._to[b]]}}d=0;for(let m=0;m<this._allData.length;m++)if(this._allData[m].from!==-2||this._allOutputIndices.indexOf(m+d)!==-1){if(d>0){let g=-1;this._allData[m].from!==void 0&&this._allData[m].from!==-1?(g=this._nodes[this._allData[m].from].outputs.indexOf(m+d),g!==-1&&(this._nodes[this._allData[m].from].outputs[g]=m)):(g=this._allInputIndices.indexOf(m+d),g!==-1&&(this._allInputIndices[g]=m)),this._allData[m].to.forEach(b=>{g=this._nodes[b].inputs.indexOf(m+d),g!==-1&&(this._nodes[b].inputs[g]=m)}),this._allData[m].to.length===0&&(g=this._allOutputIndices.indexOf(m+d),g!==-1&&(this._allOutputIndices[g]=m))}}else d++,this._allData.splice(m,1),m--}deleteNode(d){const p=this._nodes[d];if(p.outputs.length>1){for(let v=1;v<p.outputs.length;v++)if(this._allData[p.outputs[v]].to.length>0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ")}p.executeNode=!1;const _=p.inputs[0],m=p.outputs[0],g=this._allData[m].to;for(let v=0;v<p.inputs.length;v++){const T=this._allData[p.inputs[v]].to.indexOf(d);if(T===-1)throw new Error("The Value object doesn't have the current Node in it's 'to' property ");this._allData[p.inputs[v]].to.splice(T,1)}this._allData[m]._to=[];const b=this._allOutputIndices.indexOf(m);if(b!==-1&&(this._allOutputIndices[b]=_),g&&g.length>0)for(const v of g){const T=this._nodes[v].inputs.indexOf(m);if(T===-1)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[v].inputs[T]=_,this._allData[_].to.push(v)}}removeAllDropoutNodes(){let d=0;for(const p of this._nodes){if(p.opType==="Dropout"){if(p.inputs.length!==1)throw new Error("Dropout nodes should only contain one input. ");if(p.outputs.length!==1&&p.outputs.length!==2)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(p.outputs.length===2&&this._allData[p.outputs[1]]._to.length!==0)throw new Error("Dropout nodes's second output should not be referenced by other nodes");this.deleteNode(d)}d++}}removeAllIdentityNodes(){let d=0;for(const p of this._nodes)p.opType==="Identity"&&this.deleteNode(d),d++}isActivation(d){switch(d.opType){case"Relu":case"Sigmoid":case"Clip":return!0;default:return!1}}fuseConvActivationNodes(){for(const d of this._nodes)if(d.opType==="Conv"){const p=this._allData[d.outputs[0]]._to;if(p.length===1&&this.isActivation(this._nodes[p[0]])){const _=this._nodes[p[0]];if(_.opType==="Clip")if(_.inputs.length===1)try{d.attributes.set("activation_params","floats",[_.attributes.getFloat("min"),_.attributes.getFloat("max")])}catch{d.attributes.set("activation_params","floats",[l.MIN_CLIP,l.MAX_CLIP])}else{if(!(_.inputs.length>=3&&this._allData[_.inputs[1]].tensor!==void 0&&this._allData[_.inputs[2]].tensor!==void 0))continue;d.attributes.set("activation_params","floats",[this._allData[_.inputs[1]].tensor.floatData[0],this._allData[_.inputs[2]].tensor.floatData[0]])}d.attributes.set("activation","string",_.opType),this.deleteNode(p[0])}}}}},1315:(a,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.now=e.Profiler=e.Logger=void 0;const n={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},t={none:new class{log(h,u,i){}},console:new class{log(h,u,i){console.log(`${this.color(h)} ${i?"\x1B[35m"+i+"\x1B[0m ":""}${u}`)}color(h){switch(h){case"verbose":return"\x1B[34;40mv\x1B[0m";case"info":return"\x1B[32mi\x1B[0m";case"warning":return"\x1B[30;43mw\x1B[0m";case"error":return"\x1B[31;40me\x1B[0m";case"fatal":return"\x1B[101mf\x1B[0m";default:throw new Error(`unsupported severity: ${h}`)}}}},r={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1};let o={"":r};function s(h,u,i,d){if(u===void 0)return p=h,{verbose:s.verbose.bind(null,p),info:s.info.bind(null,p),warning:s.warning.bind(null,p),error:s.error.bind(null,p),fatal:s.fatal.bind(null,p)};if(i===void 0)l(h,u);else if(typeof i=="number"&&d===void 0)l(h,u);else if(typeof i=="string"&&d===void 0)l(h,i,0,u);else{if(typeof i!="string"||typeof d!="number")throw new TypeError("input is valid");l(h,i,0,u)}var p}function l(h,u,i,d){const p=o[d||""]||o[""];n[h]<n[p.minimalSeverity]||(p.logDateTime&&(u=`${new Date().toISOString()}|${u}`),p.logSourceLocation,t[p.provider].log(h,u,d))}(function(h){function u(d){o={},i("",d||{})}function i(d,p){if(d==="*")u(p);else{const _=o[d]||r;o[d]={provider:p.provider||_.provider,minimalSeverity:p.minimalSeverity||_.minimalSeverity,logDateTime:p.logDateTime===void 0?_.logDateTime:p.logDateTime,logSourceLocation:p.logSourceLocation===void 0?_.logSourceLocation:p.logSourceLocation}}}h.verbose=function(d,p){h("verbose",d,p)},h.info=function(d,p){h("info",d,p)},h.warning=function(d,p){h("warning",d,p)},h.error=function(d,p){h("error",d,p)},h.fatal=function(d,p){h("fatal",d,p)},h.reset=u,h.set=i,h.setWithEnv=function(d){const p={};d.logLevel&&(p.minimalSeverity=d.logLevel),i("",p)}})(s||(s={})),e.Logger=s;class c{constructor(u,i,d,p,_,m){this.category=u,this.name=i,this.startTime=d,this.endCallback=p,this.timer=_,this.ctx=m}async end(){return this.endCallback(this)}async checkTimer(){if(this.ctx===void 0||this.timer===void 0)throw new Error("No webgl timer found");return this.ctx.endTimer(),this.ctx.waitForQueryAndGetTime(this.timer)}}class f{constructor(u,i,d,p){this.category=u,this.name=i,this.startTime=d,this.endTime=p}}e.Profiler=class{static create(h){return h===void 0?new this:new this(h.maxNumberEvents,h.flushBatchSize,h.flushIntervalInMilliseconds)}constructor(h,u,i){this._started=!1,this._flushPointer=0,this._started=!1,this._maxNumberEvents=h===void 0?1e4:h,this._flushBatchSize=u===void 0?10:u,this._flushIntervalInMilliseconds=i===void 0?5e3:i}start(){this._started=!0,this._timingEvents=[],this._flushTime=(0,e.now)(),this._flushPointer=0}stop(){for(this._started=!1;this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer])}event(h,u,i,d){const p=this._started?this.begin(h,u,d):void 0;let _=!1;const m=i();if(m&&typeof m.then=="function")return _=!0,new Promise((g,b)=>{m.then(async v=>{p&&await p.end(),g(v)},async v=>{p&&await p.end(),b(v)})});if(!_&&p){const g=p.end();if(g&&typeof g.then=="function")return new Promise((b,v)=>{g.then(()=>{b(m)},T=>{v(T)})})}return m}begin(h,u,i){if(!this._started)throw new Error("profiler is not started yet");if(i===void 0){const d=(0,e.now)();return this.flush(d),new c(h,u,d,p=>this.endSync(p))}{const d=i.beginTimer();return new c(h,u,0,async p=>this.end(p),d,i)}}async end(h){const u=await h.checkTimer();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new f(h.category,h.name,h.startTime,u)),this.flush(u))}endSync(h){const u=(0,e.now)();this._timingEvents.length<this._maxNumberEvents&&(this._timingEvents.push(new f(h.category,h.name,h.startTime,u)),this.flush(u))}logOneEvent(h){e.Logger.verbose(`Profiler.${h.category}`,`${(h.endTime-h.startTime).toFixed(2)}ms on event '${h.name}' at ${h.endTime.toFixed(2)}`)}flush(h){if(this._timingEvents.length-this._flushPointer>=this._flushBatchSize||h-this._flushTime>=this._flushIntervalInMilliseconds){for(const u=this._flushPointer;this._flushPointer<u+this._flushBatchSize&&this._flushPointer<this._timingEvents.length;this._flushPointer++)this.logOneEvent(this._timingEvents[this._flushPointer]);this._flushTime=(0,e.now)()}}get started(){return this._started}},e.now=typeof performance<"u"&&performance.now?()=>performance.now():Date.now},1745:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Model=void 0;const t=n(5686),r=n(4662),o=n(5127),s=n(2446),l=n(7273);var c=o.onnxruntime.experimental.fbs;e.Model=class{constructor(){}load(f,h,u){if(!u)try{return void this.loadFromOnnxFormat(f,h)}catch(i){if(u!==void 0)throw i}this.loadFromOrtFormat(f,h)}loadFromOnnxFormat(f,h){const u=s.onnx.ModelProto.decode(f);if(l.LongUtil.longToNumber(u.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=u.opsetImport.map(i=>({domain:i.domain,version:l.LongUtil.longToNumber(i.version)})),this._graph=r.Graph.from(u.graph,h)}loadFromOrtFormat(f,h){const u=new t.flatbuffers.ByteBuffer(f),i=c.InferenceSession.getRootAsInferenceSession(u).model();if(l.LongUtil.longToNumber(i.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let d=0;d<i.opsetImportLength();d++){const p=i.opsetImport(d);this._opsets.push({domain:p==null?void 0:p.domain(),version:l.LongUtil.longToNumber(p.version())})}this._graph=r.Graph.from(i.graph(),h)}get graph(){return this._graph}get opsets(){return this._opsets}}},6145:(a,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.FLOAT_TYPES=e.INT_TYPES=e.NUMBER_TYPES=void 0,e.NUMBER_TYPES=["float32","float64","int32","int16","int8","uint16","uint32","uint8"],e.INT_TYPES=["int32","int16","int8","uint16","uint32","uint8"],e.FLOAT_TYPES=["float32","float64"]},5881:(a,e)=>{function n(t,r){if(r.endsWith("+")){const o=Number.parseInt(r.substring(0,r.length-1),10);return!isNaN(o)&&o<=t}if(r.split("-").length===2){const o=r.split("-"),s=Number.parseInt(o[0],10),l=Number.parseInt(o[1],10);return!isNaN(s)&&!isNaN(l)&&s<=t&&t<=l}return Number.parseInt(r,10)===t}Object.defineProperty(e,"__esModule",{value:!0}),e.resolveOperator=void 0,e.resolveOperator=function(t,r,o){for(const s of o){const l=s[0],c=s[1],f=s[2],h=s[3],u=s[4];if(t.opType===l){for(const i of r)if((i.domain===c||i.domain==="ai.onnx"&&c==="")&&n(i.version,f))return{opImpl:h,opInit:u}}}throw new TypeError(`cannot resolve operator '${t.opType}' with opsets: ${r.map(s=>`${s.domain||"ai.onnx"} v${s.version}`).join(", ")}`)}},5127:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.onnxruntime=void 0;const t=n(5686);var r,o;r=e.onnxruntime||(e.onnxruntime={}),function(s){(function(l){l[l.UNDEFINED=0]="UNDEFINED",l[l.FLOAT=1]="FLOAT",l[l.INT=2]="INT",l[l.STRING=3]="STRING",l[l.TENSOR=4]="TENSOR",l[l.GRAPH=5]="GRAPH",l[l.FLOATS=6]="FLOATS",l[l.INTS=7]="INTS",l[l.STRINGS=8]="STRINGS",l[l.TENSORS=9]="TENSORS",l[l.GRAPHS=10]="GRAPHS",l[l.SPARSE_TENSOR=11]="SPARSE_TENSOR",l[l.SPARSE_TENSORS=12]="SPARSE_TENSORS"})(s.AttributeType||(s.AttributeType={}))}((o=r.experimental||(r.experimental={})).fbs||(o.fbs={})),function(s){(function(l){(function(c){(function(f){f[f.UNKNOWN=0]="UNKNOWN",f[f.VALUE=1]="VALUE",f[f.PARAM=2]="PARAM"})(c.DimensionValueType||(c.DimensionValueType={}))})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){(function(f){f[f.UNDEFINED=0]="UNDEFINED",f[f.FLOAT=1]="FLOAT",f[f.UINT8=2]="UINT8",f[f.INT8=3]="INT8",f[f.UINT16=4]="UINT16",f[f.INT16=5]="INT16",f[f.INT32=6]="INT32",f[f.INT64=7]="INT64",f[f.STRING=8]="STRING",f[f.BOOL=9]="BOOL",f[f.FLOAT16=10]="FLOAT16",f[f.DOUBLE=11]="DOUBLE",f[f.UINT32=12]="UINT32",f[f.UINT64=13]="UINT64",f[f.COMPLEX64=14]="COMPLEX64",f[f.COMPLEX128=15]="COMPLEX128",f[f.BFLOAT16=16]="BFLOAT16",f[f.FLOAT8E4M3FN=17]="FLOAT8E4M3FN",f[f.FLOAT8E4M3FNUZ=18]="FLOAT8E4M3FNUZ",f[f.FLOAT8E5M2=19]="FLOAT8E5M2",f[f.FLOAT8E5M2FNUZ=20]="FLOAT8E5M2FNUZ"})(c.TensorDataType||(c.TensorDataType={}))})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){(function(f){f[f.Primitive=0]="Primitive",f[f.Fused=1]="Fused"})(c.NodeType||(c.NodeType={}))})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){(function(f){f[f.NONE=0]="NONE",f[f.tensor_type=1]="tensor_type",f[f.sequence_type=2]="sequence_type",f[f.map_type=3]="map_type"})(c.TypeInfoValue||(c.TypeInfoValue={}))})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsShape(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsShape(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}dim(u,i){let d=this.bb.__offset(this.bb_pos,4);return d?(i||new s.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*u),this.bb):null}dimLength(){let u=this.bb.__offset(this.bb_pos,4);return u?this.bb.__vector_len(this.bb_pos+u):0}static startShape(u){u.startObject(1)}static addDim(u,i){u.addFieldOffset(0,i,0)}static createDimVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addOffset(i[d]);return u.endVector()}static startDimVector(u,i){u.startVector(4,i,4)}static endShape(u){return u.endObject()}static createShape(u,i){return f.startShape(u),f.addDim(u,i),f.endShape(u)}}c.Shape=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsDimension(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsDimension(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}value(u){let i=this.bb.__offset(this.bb_pos,4);return i?(u||new s.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}denotation(u){let i=this.bb.__offset(this.bb_pos,6);return i?this.bb.__string(this.bb_pos+i,u):null}static startDimension(u){u.startObject(2)}static addValue(u,i){u.addFieldOffset(0,i,0)}static addDenotation(u,i){u.addFieldOffset(1,i,0)}static endDimension(u){return u.endObject()}static createDimension(u,i,d){return f.startDimension(u),f.addValue(u,i),f.addDenotation(u,d),f.endDimension(u)}}c.Dimension=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsDimensionValue(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsDimensionValue(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}dimType(){let u=this.bb.__offset(this.bb_pos,4);return u?this.bb.readInt8(this.bb_pos+u):s.experimental.fbs.DimensionValueType.UNKNOWN}dimValue(){let u=this.bb.__offset(this.bb_pos,6);return u?this.bb.readInt64(this.bb_pos+u):this.bb.createLong(0,0)}dimParam(u){let i=this.bb.__offset(this.bb_pos,8);return i?this.bb.__string(this.bb_pos+i,u):null}static startDimensionValue(u){u.startObject(3)}static addDimType(u,i){u.addFieldInt8(0,i,s.experimental.fbs.DimensionValueType.UNKNOWN)}static addDimValue(u,i){u.addFieldInt64(1,i,u.createLong(0,0))}static addDimParam(u,i){u.addFieldOffset(2,i,0)}static endDimensionValue(u){return u.endObject()}static createDimensionValue(u,i,d,p){return f.startDimensionValue(u),f.addDimType(u,i),f.addDimValue(u,d),f.addDimParam(u,p),f.endDimensionValue(u)}}c.DimensionValue=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsTensorTypeAndShape(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsTensorTypeAndShape(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}elemType(){let u=this.bb.__offset(this.bb_pos,4);return u?this.bb.readInt32(this.bb_pos+u):s.experimental.fbs.TensorDataType.UNDEFINED}shape(u){let i=this.bb.__offset(this.bb_pos,6);return i?(u||new s.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}static startTensorTypeAndShape(u){u.startObject(2)}static addElemType(u,i){u.addFieldInt32(0,i,s.experimental.fbs.TensorDataType.UNDEFINED)}static addShape(u,i){u.addFieldOffset(1,i,0)}static endTensorTypeAndShape(u){return u.endObject()}static createTensorTypeAndShape(u,i,d){return f.startTensorTypeAndShape(u),f.addElemType(u,i),f.addShape(u,d),f.endTensorTypeAndShape(u)}}c.TensorTypeAndShape=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsMapType(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsMapType(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}keyType(){let u=this.bb.__offset(this.bb_pos,4);return u?this.bb.readInt32(this.bb_pos+u):s.experimental.fbs.TensorDataType.UNDEFINED}valueType(u){let i=this.bb.__offset(this.bb_pos,6);return i?(u||new s.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}static startMapType(u){u.startObject(2)}static addKeyType(u,i){u.addFieldInt32(0,i,s.experimental.fbs.TensorDataType.UNDEFINED)}static addValueType(u,i){u.addFieldOffset(1,i,0)}static endMapType(u){return u.endObject()}static createMapType(u,i,d){return f.startMapType(u),f.addKeyType(u,i),f.addValueType(u,d),f.endMapType(u)}}c.MapType=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsSequenceType(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsSequenceType(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}elemType(u){let i=this.bb.__offset(this.bb_pos,4);return i?(u||new s.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}static startSequenceType(u){u.startObject(1)}static addElemType(u,i){u.addFieldOffset(0,i,0)}static endSequenceType(u){return u.endObject()}static createSequenceType(u,i){return f.startSequenceType(u),f.addElemType(u,i),f.endSequenceType(u)}}c.SequenceType=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(l.fbs||(l.fbs={})).EdgeEnd=class{constructor(){this.bb=null,this.bb_pos=0}__init(c,f){return this.bb_pos=c,this.bb=f,this}nodeIndex(){return this.bb.readUint32(this.bb_pos)}srcArgIndex(){return this.bb.readInt32(this.bb_pos+4)}dstArgIndex(){return this.bb.readInt32(this.bb_pos+8)}static createEdgeEnd(c,f,h,u){return c.prep(4,12),c.writeInt32(u),c.writeInt32(h),c.writeInt32(f),c.offset()}}})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsNodeEdge(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsNodeEdge(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}nodeIndex(){let u=this.bb.__offset(this.bb_pos,4);return u?this.bb.readUint32(this.bb_pos+u):0}inputEdges(u,i){let d=this.bb.__offset(this.bb_pos,6);return d?(i||new s.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+d)+12*u,this.bb):null}inputEdgesLength(){let u=this.bb.__offset(this.bb_pos,6);return u?this.bb.__vector_len(this.bb_pos+u):0}outputEdges(u,i){let d=this.bb.__offset(this.bb_pos,8);return d?(i||new s.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+d)+12*u,this.bb):null}outputEdgesLength(){let u=this.bb.__offset(this.bb_pos,8);return u?this.bb.__vector_len(this.bb_pos+u):0}static startNodeEdge(u){u.startObject(3)}static addNodeIndex(u,i){u.addFieldInt32(0,i,0)}static addInputEdges(u,i){u.addFieldOffset(1,i,0)}static startInputEdgesVector(u,i){u.startVector(12,i,4)}static addOutputEdges(u,i){u.addFieldOffset(2,i,0)}static startOutputEdgesVector(u,i){u.startVector(12,i,4)}static endNodeEdge(u){return u.endObject()}static createNodeEdge(u,i,d,p){return f.startNodeEdge(u),f.addNodeIndex(u,i),f.addInputEdges(u,d),f.addOutputEdges(u,p),f.endNodeEdge(u)}}c.NodeEdge=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsNode(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsNode(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}name(u){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.__string(this.bb_pos+i,u):null}docString(u){let i=this.bb.__offset(this.bb_pos,6);return i?this.bb.__string(this.bb_pos+i,u):null}domain(u){let i=this.bb.__offset(this.bb_pos,8);return i?this.bb.__string(this.bb_pos+i,u):null}sinceVersion(){let u=this.bb.__offset(this.bb_pos,10);return u?this.bb.readInt32(this.bb_pos+u):0}index(){let u=this.bb.__offset(this.bb_pos,12);return u?this.bb.readUint32(this.bb_pos+u):0}opType(u){let i=this.bb.__offset(this.bb_pos,14);return i?this.bb.__string(this.bb_pos+i,u):null}type(){let u=this.bb.__offset(this.bb_pos,16);return u?this.bb.readInt32(this.bb_pos+u):s.experimental.fbs.NodeType.Primitive}executionProviderType(u){let i=this.bb.__offset(this.bb_pos,18);return i?this.bb.__string(this.bb_pos+i,u):null}inputs(u,i){let d=this.bb.__offset(this.bb_pos,20);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+4*u,i):null}inputsLength(){let u=this.bb.__offset(this.bb_pos,20);return u?this.bb.__vector_len(this.bb_pos+u):0}outputs(u,i){let d=this.bb.__offset(this.bb_pos,22);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+4*u,i):null}outputsLength(){let u=this.bb.__offset(this.bb_pos,22);return u?this.bb.__vector_len(this.bb_pos+u):0}attributes(u,i){let d=this.bb.__offset(this.bb_pos,24);return d?(i||new s.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*u),this.bb):null}attributesLength(){let u=this.bb.__offset(this.bb_pos,24);return u?this.bb.__vector_len(this.bb_pos+u):0}inputArgCounts(u){let i=this.bb.__offset(this.bb_pos,26);return i?this.bb.readInt32(this.bb.__vector(this.bb_pos+i)+4*u):0}inputArgCountsLength(){let u=this.bb.__offset(this.bb_pos,26);return u?this.bb.__vector_len(this.bb_pos+u):0}inputArgCountsArray(){let u=this.bb.__offset(this.bb_pos,26);return u?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+u),this.bb.__vector_len(this.bb_pos+u)):null}implicitInputs(u,i){let d=this.bb.__offset(this.bb_pos,28);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+4*u,i):null}implicitInputsLength(){let u=this.bb.__offset(this.bb_pos,28);return u?this.bb.__vector_len(this.bb_pos+u):0}static startNode(u){u.startObject(13)}static addName(u,i){u.addFieldOffset(0,i,0)}static addDocString(u,i){u.addFieldOffset(1,i,0)}static addDomain(u,i){u.addFieldOffset(2,i,0)}static addSinceVersion(u,i){u.addFieldInt32(3,i,0)}static addIndex(u,i){u.addFieldInt32(4,i,0)}static addOpType(u,i){u.addFieldOffset(5,i,0)}static addType(u,i){u.addFieldInt32(6,i,s.experimental.fbs.NodeType.Primitive)}static addExecutionProviderType(u,i){u.addFieldOffset(7,i,0)}static addInputs(u,i){u.addFieldOffset(8,i,0)}static createInputsVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addOffset(i[d]);return u.endVector()}static startInputsVector(u,i){u.startVector(4,i,4)}static addOutputs(u,i){u.addFieldOffset(9,i,0)}static createOutputsVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addOffset(i[d]);return u.endVector()}static startOutputsVector(u,i){u.startVector(4,i,4)}static addAttributes(u,i){u.addFieldOffset(10,i,0)}static createAttributesVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addOffset(i[d]);return u.endVector()}static startAttributesVector(u,i){u.startVector(4,i,4)}static addInputArgCounts(u,i){u.addFieldOffset(11,i,0)}static createInputArgCountsVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addInt32(i[d]);return u.endVector()}static startInputArgCountsVector(u,i){u.startVector(4,i,4)}static addImplicitInputs(u,i){u.addFieldOffset(12,i,0)}static createImplicitInputsVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addOffset(i[d]);return u.endVector()}static startImplicitInputsVector(u,i){u.startVector(4,i,4)}static endNode(u){return u.endObject()}static createNode(u,i,d,p,_,m,g,b,v,T,y,w,S,O){return f.startNode(u),f.addName(u,i),f.addDocString(u,d),f.addDomain(u,p),f.addSinceVersion(u,_),f.addIndex(u,m),f.addOpType(u,g),f.addType(u,b),f.addExecutionProviderType(u,v),f.addInputs(u,T),f.addOutputs(u,y),f.addAttributes(u,w),f.addInputArgCounts(u,S),f.addImplicitInputs(u,O),f.endNode(u)}}c.Node=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsValueInfo(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsValueInfo(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}name(u){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.__string(this.bb_pos+i,u):null}docString(u){let i=this.bb.__offset(this.bb_pos,6);return i?this.bb.__string(this.bb_pos+i,u):null}type(u){let i=this.bb.__offset(this.bb_pos,8);return i?(u||new s.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}static startValueInfo(u){u.startObject(3)}static addName(u,i){u.addFieldOffset(0,i,0)}static addDocString(u,i){u.addFieldOffset(1,i,0)}static addType(u,i){u.addFieldOffset(2,i,0)}static endValueInfo(u){return u.endObject()}static createValueInfo(u,i,d,p){return f.startValueInfo(u),f.addName(u,i),f.addDocString(u,d),f.addType(u,p),f.endValueInfo(u)}}c.ValueInfo=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsTypeInfo(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsTypeInfo(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}denotation(u){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.__string(this.bb_pos+i,u):null}valueType(){let u=this.bb.__offset(this.bb_pos,6);return u?this.bb.readUint8(this.bb_pos+u):s.experimental.fbs.TypeInfoValue.NONE}value(u){let i=this.bb.__offset(this.bb_pos,8);return i?this.bb.__union(u,this.bb_pos+i):null}static startTypeInfo(u){u.startObject(3)}static addDenotation(u,i){u.addFieldOffset(0,i,0)}static addValueType(u,i){u.addFieldInt8(1,i,s.experimental.fbs.TypeInfoValue.NONE)}static addValue(u,i){u.addFieldOffset(2,i,0)}static endTypeInfo(u){return u.endObject()}static createTypeInfo(u,i,d,p){return f.startTypeInfo(u),f.addDenotation(u,i),f.addValueType(u,d),f.addValue(u,p),f.endTypeInfo(u)}}c.TypeInfo=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsOperatorSetId(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsOperatorSetId(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}domain(u){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.__string(this.bb_pos+i,u):null}version(){let u=this.bb.__offset(this.bb_pos,6);return u?this.bb.readInt64(this.bb_pos+u):this.bb.createLong(0,0)}static startOperatorSetId(u){u.startObject(2)}static addDomain(u,i){u.addFieldOffset(0,i,0)}static addVersion(u,i){u.addFieldInt64(1,i,u.createLong(0,0))}static endOperatorSetId(u){return u.endObject()}static createOperatorSetId(u,i,d){return f.startOperatorSetId(u),f.addDomain(u,i),f.addVersion(u,d),f.endOperatorSetId(u)}}c.OperatorSetId=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsTensor(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsTensor(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}name(u){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.__string(this.bb_pos+i,u):null}docString(u){let i=this.bb.__offset(this.bb_pos,6);return i?this.bb.__string(this.bb_pos+i,u):null}dims(u){let i=this.bb.__offset(this.bb_pos,8);return i?this.bb.readInt64(this.bb.__vector(this.bb_pos+i)+8*u):this.bb.createLong(0,0)}dimsLength(){let u=this.bb.__offset(this.bb_pos,8);return u?this.bb.__vector_len(this.bb_pos+u):0}dataType(){let u=this.bb.__offset(this.bb_pos,10);return u?this.bb.readInt32(this.bb_pos+u):s.experimental.fbs.TensorDataType.UNDEFINED}rawData(u){let i=this.bb.__offset(this.bb_pos,12);return i?this.bb.readUint8(this.bb.__vector(this.bb_pos+i)+u):0}rawDataLength(){let u=this.bb.__offset(this.bb_pos,12);return u?this.bb.__vector_len(this.bb_pos+u):0}rawDataArray(){let u=this.bb.__offset(this.bb_pos,12);return u?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+u),this.bb.__vector_len(this.bb_pos+u)):null}stringData(u,i){let d=this.bb.__offset(this.bb_pos,14);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+4*u,i):null}stringDataLength(){let u=this.bb.__offset(this.bb_pos,14);return u?this.bb.__vector_len(this.bb_pos+u):0}static startTensor(u){u.startObject(6)}static addName(u,i){u.addFieldOffset(0,i,0)}static addDocString(u,i){u.addFieldOffset(1,i,0)}static addDims(u,i){u.addFieldOffset(2,i,0)}static createDimsVector(u,i){u.startVector(8,i.length,8);for(let d=i.length-1;d>=0;d--)u.addInt64(i[d]);return u.endVector()}static startDimsVector(u,i){u.startVector(8,i,8)}static addDataType(u,i){u.addFieldInt32(3,i,s.experimental.fbs.TensorDataType.UNDEFINED)}static addRawData(u,i){u.addFieldOffset(4,i,0)}static createRawDataVector(u,i){u.startVector(1,i.length,1);for(let d=i.length-1;d>=0;d--)u.addInt8(i[d]);return u.endVector()}static startRawDataVector(u,i){u.startVector(1,i,1)}static addStringData(u,i){u.addFieldOffset(5,i,0)}static createStringDataVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addOffset(i[d]);return u.endVector()}static startStringDataVector(u,i){u.startVector(4,i,4)}static endTensor(u){return u.endObject()}static createTensor(u,i,d,p,_,m,g){return f.startTensor(u),f.addName(u,i),f.addDocString(u,d),f.addDims(u,p),f.addDataType(u,_),f.addRawData(u,m),f.addStringData(u,g),f.endTensor(u)}}c.Tensor=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsSparseTensor(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsSparseTensor(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}values(u){let i=this.bb.__offset(this.bb_pos,4);return i?(u||new s.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}indices(u){let i=this.bb.__offset(this.bb_pos,6);return i?(u||new s.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}dims(u){let i=this.bb.__offset(this.bb_pos,8);return i?this.bb.readInt64(this.bb.__vector(this.bb_pos+i)+8*u):this.bb.createLong(0,0)}dimsLength(){let u=this.bb.__offset(this.bb_pos,8);return u?this.bb.__vector_len(this.bb_pos+u):0}static startSparseTensor(u){u.startObject(3)}static addValues(u,i){u.addFieldOffset(0,i,0)}static addIndices(u,i){u.addFieldOffset(1,i,0)}static addDims(u,i){u.addFieldOffset(2,i,0)}static createDimsVector(u,i){u.startVector(8,i.length,8);for(let d=i.length-1;d>=0;d--)u.addInt64(i[d]);return u.endVector()}static startDimsVector(u,i){u.startVector(8,i,8)}static endSparseTensor(u){return u.endObject()}static createSparseTensor(u,i,d,p){return f.startSparseTensor(u),f.addValues(u,i),f.addIndices(u,d),f.addDims(u,p),f.endSparseTensor(u)}}c.SparseTensor=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsAttribute(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsAttribute(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}name(u){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.__string(this.bb_pos+i,u):null}docString(u){let i=this.bb.__offset(this.bb_pos,6);return i?this.bb.__string(this.bb_pos+i,u):null}type(){let u=this.bb.__offset(this.bb_pos,8);return u?this.bb.readInt32(this.bb_pos+u):s.experimental.fbs.AttributeType.UNDEFINED}f(){let u=this.bb.__offset(this.bb_pos,10);return u?this.bb.readFloat32(this.bb_pos+u):0}i(){let u=this.bb.__offset(this.bb_pos,12);return u?this.bb.readInt64(this.bb_pos+u):this.bb.createLong(0,0)}s(u){let i=this.bb.__offset(this.bb_pos,14);return i?this.bb.__string(this.bb_pos+i,u):null}t(u){let i=this.bb.__offset(this.bb_pos,16);return i?(u||new s.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}g(u){let i=this.bb.__offset(this.bb_pos,18);return i?(u||new s.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}floats(u){let i=this.bb.__offset(this.bb_pos,20);return i?this.bb.readFloat32(this.bb.__vector(this.bb_pos+i)+4*u):0}floatsLength(){let u=this.bb.__offset(this.bb_pos,20);return u?this.bb.__vector_len(this.bb_pos+u):0}floatsArray(){let u=this.bb.__offset(this.bb_pos,20);return u?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+u),this.bb.__vector_len(this.bb_pos+u)):null}ints(u){let i=this.bb.__offset(this.bb_pos,22);return i?this.bb.readInt64(this.bb.__vector(this.bb_pos+i)+8*u):this.bb.createLong(0,0)}intsLength(){let u=this.bb.__offset(this.bb_pos,22);return u?this.bb.__vector_len(this.bb_pos+u):0}strings(u,i){let d=this.bb.__offset(this.bb_pos,24);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+4*u,i):null}stringsLength(){let u=this.bb.__offset(this.bb_pos,24);return u?this.bb.__vector_len(this.bb_pos+u):0}tensors(u,i){let d=this.bb.__offset(this.bb_pos,26);return d?(i||new s.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*u),this.bb):null}tensorsLength(){let u=this.bb.__offset(this.bb_pos,26);return u?this.bb.__vector_len(this.bb_pos+u):0}graphs(u,i){let d=this.bb.__offset(this.bb_pos,28);return d?(i||new s.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*u),this.bb):null}graphsLength(){let u=this.bb.__offset(this.bb_pos,28);return u?this.bb.__vector_len(this.bb_pos+u):0}static startAttribute(u){u.startObject(13)}static addName(u,i){u.addFieldOffset(0,i,0)}static addDocString(u,i){u.addFieldOffset(1,i,0)}static addType(u,i){u.addFieldInt32(2,i,s.experimental.fbs.AttributeType.UNDEFINED)}static addF(u,i){u.addFieldFloat32(3,i,0)}static addI(u,i){u.addFieldInt64(4,i,u.createLong(0,0))}static addS(u,i){u.addFieldOffset(5,i,0)}static addT(u,i){u.addFieldOffset(6,i,0)}static addG(u,i){u.addFieldOffset(7,i,0)}static addFloats(u,i){u.addFieldOffset(8,i,0)}static createFloatsVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addFloat32(i[d]);return u.endVector()}static startFloatsVector(u,i){u.startVector(4,i,4)}static addInts(u,i){u.addFieldOffset(9,i,0)}static createIntsVector(u,i){u.startVector(8,i.length,8);for(let d=i.length-1;d>=0;d--)u.addInt64(i[d]);return u.endVector()}static startIntsVector(u,i){u.startVector(8,i,8)}static addStrings(u,i){u.addFieldOffset(10,i,0)}static createStringsVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addOffset(i[d]);return u.endVector()}static startStringsVector(u,i){u.startVector(4,i,4)}static addTensors(u,i){u.addFieldOffset(11,i,0)}static createTensorsVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addOffset(i[d]);return u.endVector()}static startTensorsVector(u,i){u.startVector(4,i,4)}static addGraphs(u,i){u.addFieldOffset(12,i,0)}static createGraphsVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addOffset(i[d]);return u.endVector()}static startGraphsVector(u,i){u.startVector(4,i,4)}static endAttribute(u){return u.endObject()}static createAttribute(u,i,d,p,_,m,g,b,v,T,y,w,S,O){return f.startAttribute(u),f.addName(u,i),f.addDocString(u,d),f.addType(u,p),f.addF(u,_),f.addI(u,m),f.addS(u,g),f.addT(u,b),f.addG(u,v),f.addFloats(u,T),f.addInts(u,y),f.addStrings(u,w),f.addTensors(u,S),f.addGraphs(u,O),f.endAttribute(u)}}c.Attribute=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsGraph(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsGraph(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}initializers(u,i){let d=this.bb.__offset(this.bb_pos,4);return d?(i||new s.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*u),this.bb):null}initializersLength(){let u=this.bb.__offset(this.bb_pos,4);return u?this.bb.__vector_len(this.bb_pos+u):0}nodeArgs(u,i){let d=this.bb.__offset(this.bb_pos,6);return d?(i||new s.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*u),this.bb):null}nodeArgsLength(){let u=this.bb.__offset(this.bb_pos,6);return u?this.bb.__vector_len(this.bb_pos+u):0}nodes(u,i){let d=this.bb.__offset(this.bb_pos,8);return d?(i||new s.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*u),this.bb):null}nodesLength(){let u=this.bb.__offset(this.bb_pos,8);return u?this.bb.__vector_len(this.bb_pos+u):0}maxNodeIndex(){let u=this.bb.__offset(this.bb_pos,10);return u?this.bb.readUint32(this.bb_pos+u):0}nodeEdges(u,i){let d=this.bb.__offset(this.bb_pos,12);return d?(i||new s.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*u),this.bb):null}nodeEdgesLength(){let u=this.bb.__offset(this.bb_pos,12);return u?this.bb.__vector_len(this.bb_pos+u):0}inputs(u,i){let d=this.bb.__offset(this.bb_pos,14);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+4*u,i):null}inputsLength(){let u=this.bb.__offset(this.bb_pos,14);return u?this.bb.__vector_len(this.bb_pos+u):0}outputs(u,i){let d=this.bb.__offset(this.bb_pos,16);return d?this.bb.__string(this.bb.__vector(this.bb_pos+d)+4*u,i):null}outputsLength(){let u=this.bb.__offset(this.bb_pos,16);return u?this.bb.__vector_len(this.bb_pos+u):0}sparseInitializers(u,i){let d=this.bb.__offset(this.bb_pos,18);return d?(i||new s.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*u),this.bb):null}sparseInitializersLength(){let u=this.bb.__offset(this.bb_pos,18);return u?this.bb.__vector_len(this.bb_pos+u):0}static startGraph(u){u.startObject(8)}static addInitializers(u,i){u.addFieldOffset(0,i,0)}static createInitializersVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addOffset(i[d]);return u.endVector()}static startInitializersVector(u,i){u.startVector(4,i,4)}static addNodeArgs(u,i){u.addFieldOffset(1,i,0)}static createNodeArgsVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addOffset(i[d]);return u.endVector()}static startNodeArgsVector(u,i){u.startVector(4,i,4)}static addNodes(u,i){u.addFieldOffset(2,i,0)}static createNodesVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addOffset(i[d]);return u.endVector()}static startNodesVector(u,i){u.startVector(4,i,4)}static addMaxNodeIndex(u,i){u.addFieldInt32(3,i,0)}static addNodeEdges(u,i){u.addFieldOffset(4,i,0)}static createNodeEdgesVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addOffset(i[d]);return u.endVector()}static startNodeEdgesVector(u,i){u.startVector(4,i,4)}static addInputs(u,i){u.addFieldOffset(5,i,0)}static createInputsVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addOffset(i[d]);return u.endVector()}static startInputsVector(u,i){u.startVector(4,i,4)}static addOutputs(u,i){u.addFieldOffset(6,i,0)}static createOutputsVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addOffset(i[d]);return u.endVector()}static startOutputsVector(u,i){u.startVector(4,i,4)}static addSparseInitializers(u,i){u.addFieldOffset(7,i,0)}static createSparseInitializersVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addOffset(i[d]);return u.endVector()}static startSparseInitializersVector(u,i){u.startVector(4,i,4)}static endGraph(u){return u.endObject()}static createGraph(u,i,d,p,_,m,g,b,v){return f.startGraph(u),f.addInitializers(u,i),f.addNodeArgs(u,d),f.addNodes(u,p),f.addMaxNodeIndex(u,_),f.addNodeEdges(u,m),f.addInputs(u,g),f.addOutputs(u,b),f.addSparseInitializers(u,v),f.endGraph(u)}}c.Graph=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsModel(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsModel(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}irVersion(){let u=this.bb.__offset(this.bb_pos,4);return u?this.bb.readInt64(this.bb_pos+u):this.bb.createLong(0,0)}opsetImport(u,i){let d=this.bb.__offset(this.bb_pos,6);return d?(i||new s.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*u),this.bb):null}opsetImportLength(){let u=this.bb.__offset(this.bb_pos,6);return u?this.bb.__vector_len(this.bb_pos+u):0}producerName(u){let i=this.bb.__offset(this.bb_pos,8);return i?this.bb.__string(this.bb_pos+i,u):null}producerVersion(u){let i=this.bb.__offset(this.bb_pos,10);return i?this.bb.__string(this.bb_pos+i,u):null}domain(u){let i=this.bb.__offset(this.bb_pos,12);return i?this.bb.__string(this.bb_pos+i,u):null}modelVersion(){let u=this.bb.__offset(this.bb_pos,14);return u?this.bb.readInt64(this.bb_pos+u):this.bb.createLong(0,0)}docString(u){let i=this.bb.__offset(this.bb_pos,16);return i?this.bb.__string(this.bb_pos+i,u):null}graph(u){let i=this.bb.__offset(this.bb_pos,18);return i?(u||new s.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}graphDocString(u){let i=this.bb.__offset(this.bb_pos,20);return i?this.bb.__string(this.bb_pos+i,u):null}static startModel(u){u.startObject(9)}static addIrVersion(u,i){u.addFieldInt64(0,i,u.createLong(0,0))}static addOpsetImport(u,i){u.addFieldOffset(1,i,0)}static createOpsetImportVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addOffset(i[d]);return u.endVector()}static startOpsetImportVector(u,i){u.startVector(4,i,4)}static addProducerName(u,i){u.addFieldOffset(2,i,0)}static addProducerVersion(u,i){u.addFieldOffset(3,i,0)}static addDomain(u,i){u.addFieldOffset(4,i,0)}static addModelVersion(u,i){u.addFieldInt64(5,i,u.createLong(0,0))}static addDocString(u,i){u.addFieldOffset(6,i,0)}static addGraph(u,i){u.addFieldOffset(7,i,0)}static addGraphDocString(u,i){u.addFieldOffset(8,i,0)}static endModel(u){return u.endObject()}static createModel(u,i,d,p,_,m,g,b,v,T){return f.startModel(u),f.addIrVersion(u,i),f.addOpsetImport(u,d),f.addProducerName(u,p),f.addProducerVersion(u,_),f.addDomain(u,m),f.addModelVersion(u,g),f.addDocString(u,b),f.addGraph(u,v),f.addGraphDocString(u,T),f.endModel(u)}}c.Model=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsKernelCreateInfos(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsKernelCreateInfos(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}nodeIndices(u){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.readUint32(this.bb.__vector(this.bb_pos+i)+4*u):0}nodeIndicesLength(){let u=this.bb.__offset(this.bb_pos,4);return u?this.bb.__vector_len(this.bb_pos+u):0}nodeIndicesArray(){let u=this.bb.__offset(this.bb_pos,4);return u?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+u),this.bb.__vector_len(this.bb_pos+u)):null}kernelDefHashes(u){let i=this.bb.__offset(this.bb_pos,6);return i?this.bb.readUint64(this.bb.__vector(this.bb_pos+i)+8*u):this.bb.createLong(0,0)}kernelDefHashesLength(){let u=this.bb.__offset(this.bb_pos,6);return u?this.bb.__vector_len(this.bb_pos+u):0}static startKernelCreateInfos(u){u.startObject(2)}static addNodeIndices(u,i){u.addFieldOffset(0,i,0)}static createNodeIndicesVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addInt32(i[d]);return u.endVector()}static startNodeIndicesVector(u,i){u.startVector(4,i,4)}static addKernelDefHashes(u,i){u.addFieldOffset(1,i,0)}static createKernelDefHashesVector(u,i){u.startVector(8,i.length,8);for(let d=i.length-1;d>=0;d--)u.addInt64(i[d]);return u.endVector()}static startKernelDefHashesVector(u,i){u.startVector(8,i,8)}static endKernelCreateInfos(u){return u.endObject()}static createKernelCreateInfos(u,i,d){return f.startKernelCreateInfos(u),f.addNodeIndices(u,i),f.addKernelDefHashes(u,d),f.endKernelCreateInfos(u)}}c.KernelCreateInfos=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsSubGraphSessionState(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsSubGraphSessionState(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}graphId(u){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.__string(this.bb_pos+i,u):null}sessionState(u){let i=this.bb.__offset(this.bb_pos,6);return i?(u||new s.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}static startSubGraphSessionState(u){u.startObject(2)}static addGraphId(u,i){u.addFieldOffset(0,i,0)}static addSessionState(u,i){u.addFieldOffset(1,i,0)}static endSubGraphSessionState(u){let i=u.endObject();return u.requiredField(i,4),i}static createSubGraphSessionState(u,i,d){return f.startSubGraphSessionState(u),f.addGraphId(u,i),f.addSessionState(u,d),f.endSubGraphSessionState(u)}}c.SubGraphSessionState=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsSessionState(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsSessionState(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}kernels(u){let i=this.bb.__offset(this.bb_pos,4);return i?(u||new s.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}subGraphSessionStates(u,i){let d=this.bb.__offset(this.bb_pos,6);return d?(i||new s.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+d)+4*u),this.bb):null}subGraphSessionStatesLength(){let u=this.bb.__offset(this.bb_pos,6);return u?this.bb.__vector_len(this.bb_pos+u):0}static startSessionState(u){u.startObject(2)}static addKernels(u,i){u.addFieldOffset(0,i,0)}static addSubGraphSessionStates(u,i){u.addFieldOffset(1,i,0)}static createSubGraphSessionStatesVector(u,i){u.startVector(4,i.length,4);for(let d=i.length-1;d>=0;d--)u.addOffset(i[d]);return u.endVector()}static startSubGraphSessionStatesVector(u,i){u.startVector(4,i,4)}static endSessionState(u){return u.endObject()}static createSessionState(u,i,d){return f.startSessionState(u),f.addKernels(u,i),f.addSubGraphSessionStates(u,d),f.endSessionState(u)}}c.SessionState=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={})),function(s){(function(l){(function(c){class f{constructor(){this.bb=null,this.bb_pos=0}__init(u,i){return this.bb_pos=u,this.bb=i,this}static getRootAsInferenceSession(u,i){return(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static getSizePrefixedRootAsInferenceSession(u,i){return u.setPosition(u.position()+t.flatbuffers.SIZE_PREFIX_LENGTH),(i||new f).__init(u.readInt32(u.position())+u.position(),u)}static bufferHasIdentifier(u){return u.__has_identifier("ORTM")}ortVersion(u){let i=this.bb.__offset(this.bb_pos,4);return i?this.bb.__string(this.bb_pos+i,u):null}model(u){let i=this.bb.__offset(this.bb_pos,6);return i?(u||new s.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}sessionState(u){let i=this.bb.__offset(this.bb_pos,8);return i?(u||new s.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+i),this.bb):null}static startInferenceSession(u){u.startObject(3)}static addOrtVersion(u,i){u.addFieldOffset(0,i,0)}static addModel(u,i){u.addFieldOffset(1,i,0)}static addSessionState(u,i){u.addFieldOffset(2,i,0)}static endInferenceSession(u){return u.endObject()}static finishInferenceSessionBuffer(u,i){u.finish(i,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(u,i){u.finish(i,"ORTM",!0)}static createInferenceSession(u,i,d,p){return f.startInferenceSession(u),f.addOrtVersion(u,i),f.addModel(u,d),f.addSessionState(u,p),f.endInferenceSession(u)}}c.InferenceSession=f})(l.fbs||(l.fbs={}))})(s.experimental||(s.experimental={}))}(e.onnxruntime||(e.onnxruntime={}))},1723:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OnnxjsSessionHandler=void 0;const t=n(2235),r=n(9240);e.OnnxjsSessionHandler=class{constructor(o){this.session=o,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(o,s,l){const c=new Map;for(const u in o)if(Object.hasOwnProperty.call(o,u)){const i=o[u];c.set(u,new r.Tensor(i.dims,i.type,void 0,void 0,i.data))}const f=await this.session.run(c),h={};return f.forEach((u,i)=>{h[i]=new t.Tensor(u.type,u.data,u.dims)}),h}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}},6027:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Session=void 0;const t=n(7067),r=n(1296),o=n(1975),s=n(6496),l=n(1315),c=n(1745);e.Session=class{constructor(f={}){this._initialized=!1,this.backendHint=f.backendHint,this.profiler=l.Profiler.create(f.profiler),this.context={profiler:this.profiler,graphInputTypes:[],graphInputDims:[]}}get inputNames(){return this._model.graph.getInputNames()}get outputNames(){return this._model.graph.getOutputNames()}startProfiling(){this.profiler.start()}endProfiling(){this.profiler.stop()}async loadModel(f,h,u){await this.profiler.event("session","Session.loadModel",async()=>{const i=await(0,o.resolveBackend)(this.backendHint);if(this.sessionHandler=i.createSessionHandler(this.context),this._model=new c.Model,typeof f=="string"){const d=f.endsWith(".ort");if(typeof process<"u"&&process.versions&&process.versions.node){const p=await(0,r.promisify)(t.readFile)(f);this.initialize(p,d)}else{const p=await fetch(f),_=await p.arrayBuffer();this.initialize(new Uint8Array(_),d)}}else if(ArrayBuffer.isView(f))this.initialize(f);else{const d=new Uint8Array(f,h||0,u||f.byteLength);this.initialize(d)}})}initialize(f,h){if(this._initialized)throw new Error("already initialized");this.profiler.event("session","Session.initialize",()=>{const u=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(f,u,h),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new s.ExecutionPlan(this._model.graph,this._ops,this.profiler)}),this._initialized=!0}async run(f){if(!this._initialized)throw new Error("session not initialized yet");return this.profiler.event("session","Session.run",async()=>{const h=this.normalizeAndValidateInputs(f),u=await this._executionPlan.execute(this.sessionHandler,h);return this.createOutput(u)})}normalizeAndValidateInputs(f){const h=this._model.graph.getInputNames();if(Array.isArray(f)){if(f.length!==h.length)throw new Error(`incorrect input array length: expected ${h.length} but got ${f.length}`)}else{if(f.size!==h.length)throw new Error(`incorrect input map size: expected ${h.length} but got ${f.size}`);const u=new Array(f.size);let i=0;for(let d=0;d<h.length;++d){const p=f.get(h[d]);if(!p)throw new Error(`missing input tensor for: '${name}'`);u[i++]=p}f=u}if(this.context.graphInputTypes&&this.context.graphInputTypes.length!==0&&this.context.graphInputDims&&this.context.graphInputDims.length!==0)this.validateInputTensorDims(this.context.graphInputDims,f,!1);else{const u=this._model.graph.getInputIndices(),i=this._model.graph.getValues(),d=new Array(u.length);for(let p=0;p<u.length;++p){const _=i[u[p]];d[p]=_.type.shape.dims,this.context.graphInputTypes.push(_.type.tensorType),this.context.graphInputDims.push(f[p].dims)}this.validateInputTensorDims(d,f,!0)}return this.validateInputTensorTypes(this.context.graphInputTypes,f),f}validateInputTensorTypes(f,h){for(let u=0;u<h.length;u++){const i=f[u],d=h[u].type;if(i!==d)throw new Error(`input tensor[${u}] check failed: expected type '${i}' but got ${d}`)}}validateInputTensorDims(f,h,u){for(let i=0;i<h.length;i++){const d=f[i],p=h[i].dims;if(!this.compareTensorDims(d,p,u))throw new Error(`input tensor[${i}] check failed: expected shape '[${d.join(",")}]' but got [${p.join(",")}]`)}}compareTensorDims(f,h,u){if(f.length!==h.length)return!1;for(let i=0;i<f.length;++i)if(f[i]!==h[i]&&(!u||f[i]!==0))return!1;return!0}createOutput(f){const h=this._model.graph.getOutputNames();if(f.length!==h.length)throw new Error("expected number of outputs do not match number of generated outputs");const u=new Map;for(let i=0;i<h.length;++i)u.set(h[i],f[i]);return u}initializeOps(f){const h=f.getNodes();this._ops=new Array(h.length);for(let u=0;u<h.length;u++)this._ops[u]=this.sessionHandler.resolve(h[u],this._model.opsets,f)}}},9240:function(a,e,n){var t=this&&this.__importDefault||function(_){return _&&_.__esModule?_:{default:_}};Object.defineProperty(e,"__esModule",{value:!0}),e.Tensor=void 0;const r=n(3442),o=t(n(1583)),s=n(5127),l=n(2446),c=n(7273);var f=s.onnxruntime.experimental.fbs;class h{get data(){if(this.cache===void 0){const m=this.dataProvider(this.dataId);if(m.length!==this.size)throw new Error("Length of data provided by the Data Provider is inconsistent with the dims of this Tensor.");this.cache=m}return this.cache}get stringData(){if(this.type!=="string")throw new TypeError("data type is not string");return this.data}get integerData(){switch(this.type){case"uint8":case"int8":case"uint16":case"int16":case"int32":case"uint32":case"bool":return this.data;default:throw new TypeError("data type is not integer (uint8, int8, uint16, int16, int32, uint32, bool)")}}get floatData(){switch(this.type){case"float32":case"float64":return this.data;default:throw new TypeError("data type is not float (float32, float64)")}}get numberData(){if(this.type!=="string")return this.data;throw new TypeError("type cannot be non-number (string)")}get(m){return this.data[c.ShapeUtil.indicesToOffset(m,this.strides)]}set(m,g){this.data[c.ShapeUtil.indicesToOffset(m,this.strides)]=g}async getData(){return this.cache===void 0&&(this.cache=await this.asyncDataProvider(this.dataId)),this.cache}get strides(){return this._strides||(this._strides=c.ShapeUtil.computeStrides(this.dims)),this._strides}constructor(m,g,b,v,T,y=r.Guid.create()){this.dims=m,this.type=g,this.dataProvider=b,this.asyncDataProvider=v,this.cache=T,this.dataId=y,this.size=c.ShapeUtil.validateDimsAndCalcSize(m);const w=this.size,S=b===void 0&&v===void 0&&T===void 0;if(T!==void 0&&T.length!==w)throw new RangeError("Input dims doesn't match data length.");if(g==="string"){if(!(T===void 0||Array.isArray(T)&&T.every(O=>typeof O=="string")))throw new TypeError("cache should be a string array");S&&(this.cache=new Array(w))}else{if(T!==void 0){const O=i(g);if(!(T instanceof O))throw new TypeError(`cache should be type ${O.name}`)}if(S){const O=new ArrayBuffer(w*function(P){switch(P){case"bool":case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;case"float64":return 8;default:throw new Error(`cannot calculate sizeof() on type ${P}`)}}(g));this.cache=function(P,E){return new(i(E))(P)}(O,g)}}}static fromProto(m){if(!m)throw new Error("cannot construct Value from an empty tensor");const g=c.ProtoUtil.tensorDataTypeFromProto(m.dataType),b=c.ProtoUtil.tensorDimsFromProto(m.dims),v=new h(b,g);if(g==="string")m.stringData.forEach((T,y)=>{v.data[y]=(0,c.decodeUtf8String)(T)});else if(m.rawData&&typeof m.rawData.byteLength=="number"&&m.rawData.byteLength>0){const T=v.data,y=new DataView(m.rawData.buffer,m.rawData.byteOffset,m.rawData.byteLength),w=u(m.dataType),S=m.rawData.byteLength/w;if(m.rawData.byteLength%w!=0)throw new Error("invalid buffer length");if(T.length!==S)throw new Error("buffer length mismatch");for(let O=0;O<S;O++){const P=p(y,m.dataType,O*w);T[O]=P}}else{let T;switch(m.dataType){case l.onnx.TensorProto.DataType.FLOAT:T=m.floatData;break;case l.onnx.TensorProto.DataType.INT32:case l.onnx.TensorProto.DataType.INT16:case l.onnx.TensorProto.DataType.UINT16:case l.onnx.TensorProto.DataType.INT8:case l.onnx.TensorProto.DataType.UINT8:case l.onnx.TensorProto.DataType.BOOL:T=m.int32Data;break;case l.onnx.TensorProto.DataType.INT64:T=m.int64Data;break;case l.onnx.TensorProto.DataType.DOUBLE:T=m.doubleData;break;case l.onnx.TensorProto.DataType.UINT32:case l.onnx.TensorProto.DataType.UINT64:T=m.uint64Data;break;default:throw new Error("unspecific error")}if(T==null)throw new Error("failed to populate data from a tensorproto value");const y=v.data;if(y.length!==T.length)throw new Error("array length mismatch");for(let w=0;w<T.length;w++){const S=T[w];o.default.isLong(S)?y[w]=d(S,m.dataType):y[w]=S}}return v}static fromData(m,g,b){return new h(g,b,void 0,void 0,m)}static fromOrtTensor(m){if(!m)throw new Error("cannot construct Value from an empty tensor");const g=c.ProtoUtil.tensorDimsFromORTFormat(m),b=c.ProtoUtil.tensorDataTypeFromProto(m.dataType()),v=new h(g,b);if(b==="string")for(let T=0;T<m.stringDataLength();T++)v.data[T]=m.stringData(T);else if(m.rawDataArray()&&typeof m.rawDataLength()=="number"&&m.rawDataLength()>0){const T=v.data,y=new DataView(m.rawDataArray().buffer,m.rawDataArray().byteOffset,m.rawDataLength()),w=u(m.dataType()),S=m.rawDataLength()/w;if(m.rawDataLength()%w!=0)throw new Error("invalid buffer length");if(T.length!==S)throw new Error("buffer length mismatch");for(let O=0;O<S;O++){const P=p(y,m.dataType(),O*w);T[O]=P}}return v}}function u(_){switch(_){case l.onnx.TensorProto.DataType.UINT8:case l.onnx.TensorProto.DataType.INT8:case l.onnx.TensorProto.DataType.BOOL:return 1;case l.onnx.TensorProto.DataType.UINT16:case l.onnx.TensorProto.DataType.INT16:return 2;case l.onnx.TensorProto.DataType.FLOAT:case l.onnx.TensorProto.DataType.INT32:case l.onnx.TensorProto.DataType.UINT32:return 4;case l.onnx.TensorProto.DataType.INT64:case l.onnx.TensorProto.DataType.DOUBLE:case l.onnx.TensorProto.DataType.UINT64:return 8;default:throw new Error(`cannot calculate sizeof() on type ${l.onnx.TensorProto.DataType[_]}`)}}function i(_){switch(_){case"bool":case"uint8":return Uint8Array;case"int8":return Int8Array;case"int16":return Int16Array;case"uint16":return Uint16Array;case"int32":return Int32Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"float32":return Float32Array;case"float64":return Float64Array;default:throw new Error("unspecified error")}}function d(_,m){if(m===l.onnx.TensorProto.DataType.INT64||m===f.TensorDataType.INT64){if(_.greaterThanOrEqual(2147483648)||_.lessThan(-2147483648))throw new TypeError("int64 is not supported")}else{if(m!==l.onnx.TensorProto.DataType.UINT32&&m!==f.TensorDataType.UINT32&&m!==l.onnx.TensorProto.DataType.UINT64&&m!==f.TensorDataType.UINT64)throw new TypeError(`not a LONG type: ${l.onnx.TensorProto.DataType[m]}`);if(_.greaterThanOrEqual(4294967296)||_.lessThan(0))throw new TypeError("uint64 is not supported")}return _.toNumber()}function p(_,m,g){switch(m){case l.onnx.TensorProto.DataType.BOOL:case l.onnx.TensorProto.DataType.UINT8:return _.getUint8(g);case l.onnx.TensorProto.DataType.INT8:return _.getInt8(g);case l.onnx.TensorProto.DataType.UINT16:return _.getUint16(g,!0);case l.onnx.TensorProto.DataType.INT16:return _.getInt16(g,!0);case l.onnx.TensorProto.DataType.FLOAT:return _.getFloat32(g,!0);case l.onnx.TensorProto.DataType.INT32:return _.getInt32(g,!0);case l.onnx.TensorProto.DataType.UINT32:return _.getUint32(g,!0);case l.onnx.TensorProto.DataType.INT64:return d(o.default.fromBits(_.getUint32(g,!0),_.getUint32(g+4,!0),!1),m);case l.onnx.TensorProto.DataType.DOUBLE:return _.getFloat64(g,!0);case l.onnx.TensorProto.DataType.UINT64:return d(o.default.fromBits(_.getUint32(g,!0),_.getUint32(g+4,!0),!0),m);default:throw new Error(`cannot read from DataView for type ${l.onnx.TensorProto.DataType[m]}`)}}e.Tensor=h},7273:function(a,e,n){var t=this&&this.__importDefault||function(m){return m&&m.__esModule?m:{default:m}};Object.defineProperty(e,"__esModule",{value:!0}),e.decodeUtf8String=e.MAX_CLIP=e.MIN_CLIP=e.PoolConvUtil=e.ReduceUtil=e.SplitUtil=e.MathUtil=e.ShapeUtil=e.LongUtil=e.ProtoUtil=e.GemmUtil=e.arrayCopyHelper=e.BroadcastUtil=e.MatMulUtil=e.ArrayUtil=e.assert=e.checkInputsShape=void 0;const r=n(5686),o=t(n(1583)),s=n(2446),l=n(9240);e.checkInputsShape=function(m,...g){if(!m||m.length!==g.length)return!1;for(let b=0;b<m.length;b++)if(!m[b].dims||m[b].dims.length!==g[b])return!1;return!0},e.assert=function(m,g){if(!m)throw new Error(typeof g=="string"?g:g())},e.ArrayUtil=class{static arraysEqual(m,g){if(m.length!==g.length)return!1;for(let b=0;b<m.length;b++)if(m[b]!==g[b])return!1;return!0}};class c{static preprocessInputShapes(g,b){return[g.length===1?[1,g[0]]:g,b.length===1?[b[0],1]:b]}static postprocessOutputShape(g,b,v){b===1&&g.splice(g.length-2,1),v===1&&g.pop()}static calcMatMulShape(g,b){return g[1]!==b[0]?void 0:[g[0],b[1]]}}e.MatMulUtil=c;class f{static calcShape(g,b,v=!1){const T=g.length,y=b.length;if(T===0)return b;if(y===0)return g;const w=Math.max(g.length,b.length),S=new Array(w);if(v){if(T<2||y<2)return;const O=c.calcMatMulShape([g[T-2],g[T-1]],[b[y-2],b[y-1]]);if(O===void 0)return;[S[w-2],S[w-1]]=O}for(let O=v?3:1;O<=w;O++){const P=T-O<0?1:g[T-O],E=y-O<0?1:b[y-O];if(P!==E&&P>1&&E>1)return;S[w-O]=Math.max(P,E)}return S}static index(g,b){const v=new Array(b.length);return f.fillIndex(g,b,v),v}static fillIndex(g,b,v){const T=g.length-b.length;for(let y=0;y<b.length;y++)v[y]=g[T+y]%b[y]}static calc(g,b,v,T,y){const w=f.calcShape(g.dims,b.dims);if(w){if(T&&!i.areEqual(w,g.dims))return;const S=i.size(w),O=T?g:new l.Tensor(w,y||g.type);if(w.length===0)O.set([],v(g.get([]),b.get([])));else{const P=new Array(w.length),E=new Array(g.dims.length),A=new Array(b.dims.length);let $,k=0,D=0,I=!1,C=!1;g.dims.length===0&&(k=g.get([]),I=!0),b.dims.length===0&&(D=b.get([]),C=!0);for(let L=0;L<S;L++){$=L;for(let K=w.length-1;K>=0;K--)P[K]=$%w[K],$=Math.floor($/w[K]);I||(f.fillIndex(P,g.dims,E),k=g.get(E)),C||(f.fillIndex(P,b.dims,A),D=b.get(A)),O.set(P,v(k,D))}}return O}}static isValidBroadcast(g,b){const v=g.length,T=b.length;if(v>T)return!1;for(let y=1;y<=v;y++)if(g[v-y]!==1&&g[v-y]!==b[T-y])return!1;return!0}static getBroadcastDims(g,b){const v=g.length,T=[];for(let y=0;y<v;y++){const w=v-1-y,S=g[w]||1;(b[b.length-1-y]||1)>1&&S===1&&T.unshift(w)}return T}}e.BroadcastUtil=f,e.arrayCopyHelper=function(m,g,b,v,T){if(v<0||v>=g.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(v+T>g.length)throw new Error("source indices to be copied are outside bounds");if(b+T>m.length)throw new Error("target array is too small to hold result");for(let y=0;y<T;y++)m[b+y]=g[v+y]},e.GemmUtil=class{static getShapeOfGemmResult(m,g,b,v,T){if(m.length!==2||b.length!==2)throw new Error("shape need to be of size 2");let y,w,S;g?(y=m[1],w=m[0]):(y=m[0],w=m[1]);let O=-1;if(v?(S=b[0],O=1):(S=b[1],O=0),b[O]!==w)throw new Error("dimension mismatch");if(y<=0||S<=0||w<=0)throw new Error("invalid shape specified");if(T&&!f.isValidBroadcast(T,[y,S]))throw new Error("gemm: invalid bias shape for broadcast");return[y,S,w]}};class h{static tensorDataTypeFromProto(g){switch(g){case s.onnx.TensorProto.DataType.INT8:return"int8";case s.onnx.TensorProto.DataType.UINT8:return"uint8";case s.onnx.TensorProto.DataType.BOOL:return"bool";case s.onnx.TensorProto.DataType.INT16:return"int16";case s.onnx.TensorProto.DataType.UINT16:return"uint16";case s.onnx.TensorProto.DataType.INT32:return"int32";case s.onnx.TensorProto.DataType.UINT32:return"uint32";case s.onnx.TensorProto.DataType.FLOAT:return"float32";case s.onnx.TensorProto.DataType.DOUBLE:return"float64";case s.onnx.TensorProto.DataType.STRING:return"string";case s.onnx.TensorProto.DataType.INT64:return"int32";case s.onnx.TensorProto.DataType.UINT64:return"uint32";default:throw new Error(`unsupported data type: ${s.onnx.TensorProto.DataType[g]}`)}}static tensorDataTypeStringToEnum(g){switch(g){case"int8":return s.onnx.TensorProto.DataType.INT8;case"uint8":return s.onnx.TensorProto.DataType.UINT8;case"bool":return s.onnx.TensorProto.DataType.BOOL;case"int16":return s.onnx.TensorProto.DataType.INT16;case"uint16":return s.onnx.TensorProto.DataType.UINT16;case"int32":return s.onnx.TensorProto.DataType.INT32;case"uint32":return s.onnx.TensorProto.DataType.UINT32;case"float32":return s.onnx.TensorProto.DataType.FLOAT;case"float64":return s.onnx.TensorProto.DataType.DOUBLE;case"string":return s.onnx.TensorProto.DataType.STRING;case"int64":return s.onnx.TensorProto.DataType.INT64;case"uint64":return s.onnx.TensorProto.DataType.UINT64;default:throw new Error(`unsupported data type: ${g}`)}}static tensorDimsFromProto(g){return g.map(b=>o.default.isLong(b)?b.toNumber():b)}static tensorValueTypeFromProto(g){return{tensorType:h.tensorDataTypeFromProto(g.elemType),shape:{dims:h.tensorDimsFromProto(g.shape.dim.map(b=>b.dimValue))}}}static tensorDimsFromORTFormat(g){const b=[];for(let v=0;v<g.dimsLength();v++)b.push(u.longToNumber(g.dims(v)));return b}static tensorAttributesFromORTFormat(g){const b=[];for(let v=0;v<g.attributesLength();v++)b.push(g.attributes(v));return b}}e.ProtoUtil=h;class u{static longToNumber(g,b){return o.default.isLong(g)?g.toNumber():g instanceof r.flatbuffers.Long?o.default.fromValue({low:g.low,high:g.high,unsigned:b!=null&&b}).toNumber():g}static isLong(g){return o.default.isLong(g)||g instanceof r.flatbuffers.Long}}e.LongUtil=u;class i{static size(g){return i.getSizeFromDimensionRange(g,0,g.length)}static sizeFromDimension(g,b){if(b<0||b>g.length)throw new Error(`invalid dimension of ${b} for sizeFromDimension as Tensor has ${g.length} dimensions.`);return i.getSizeFromDimensionRange(g,b,g.length)}static sizeToDimension(g,b){if(b<0||b>g.length)throw new Error(`invalid dimension of ${b} for sizeToDimension as Tensor has ${g.length} dimensions.`);return i.getSizeFromDimensionRange(g,0,b)}static getSizeFromDimensionRange(g,b,v){let T=1;for(let y=b;y<v;y++){if(g[y]<=0)throw new Error("cannot get valid size from specified dimension range. Most likely the range contains 0 or negative values in them.");T*=g[y]}return T}static computeStrides(g){const b=g.length;if(b===0)return[];if(b===1)return[1];const v=new Array(b);v[b-1]=1,v[b-2]=g[b-1];for(let T=b-3;T>=0;--T)v[T]=v[T+1]*g[T+1];return v}static transpose(g){return g.slice().reverse()}static indicesToOffset(g,b,v){v===void 0&&(v=g.length);let T=0;for(let y=0;y<v;++y)T+=b[y]*g[y];return T}static offsetToIndices(g,b){const v=b.length;if(v===0)return[];if(v===1)return[g*b[0]];const T=new Array(b.length);for(let y=0;y<T.length-1;++y)T[y]=Math.floor(g/b[y]),g-=T[y]*b[y];return T[T.length-1]=g,T}static normalizeAxis(g,b){if(g<-b&&g>=b)throw new Error("unsupported axis for this operation.");return g<0?g+b:g}static normalizeAxes(g,b){return g.map(v=>this.normalizeAxis(v,b))}static incrementIndex(g,b,v){if(b.length===0||g.length===0)throw new Error("Index incrementing unsupported for scalar Tensor");if(v===void 0)v=b.length;else if(v<=0||v>b.length)throw new Error("Incorrect axis to increment on");for(let T=v-1;T>=0&&(g[T]++,!(g[T]<b[T]));--T)g[T]=0}static calculateReshapedDims(g,b){if(b.length===0){if(g.length===0||i.size(g)===1)return[];throw new Error("cannot reshape to a scalar Tensor")}const v=b.length,T=new Array(v);let y=-1,w=1;for(let O=0;O<v;O++){if(b[O]<-1)throw new Error("a dimension in shape hints cannot be less than -1");if(b[O]===-1){if(y!==-1)throw new Error("at most one dimension in shape hints can be -1");y=O}else{if(b[O]===0){if(O>=g.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");T[O]=g[O]}else T[O]=b[O];w*=T[O]}}const S=i.size(g);if(y!==-1){if(S%w!=0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${g}] Output shape: [${b}]`);T[y]=S/w}else if(w!==S)throw new Error("reshapedDims and originalDims don't have matching sizes");return T}static sortBasedOnPerm(g,b){return b?b.map(v=>g[v]):g.slice().reverse()}static padShape(g,b){const v=g.length;return g.map((T,y)=>T+b[y]+b[y+v])}static areEqual(g,b){return g.length===b.length&&g.every((v,T)=>v===b[T])}static validateDimsAndCalcSize(g){if(g.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let b=1;for(const v of g){if(!Number.isInteger(v))throw new TypeError(`Invalid shape: ${v} is not an integer`);if(v<0||v>2147483647)throw new TypeError(`Invalid shape: length ${v} is not allowed`);b*=v}return b}static flattenShape(g,b){b<0&&(b+=g.length);const v=g.reduce((y,w)=>y*w,1),T=g.slice(b).reduce((y,w)=>y*w,1);return[v/T,T]}static squeezeShape(g,b){const v=new Array;b=i.normalizeAxes(b,g.length);for(let T=0;T<g.length;T++){const y=b.indexOf(T)>=0;if(y&&g[T]!==1)throw new Error("squeeze an axis of size different than 1");(b.length===0&&g[T]>1||b.length>0&&!y)&&v.push(g[T])}return v}static unsqueezeShape(g,b){const v=new Array(g.length+b.length);v.fill(0);for(let y=0;y<b.length;y++){const w=i.normalizeAxis(b[y],v.length);if(w>=v.length)throw new Error("'axes' has an out of range axis");if(v[w]!==0)throw new Error("'axes' has a duplicate axis");v[w]=1}let T=0;for(let y=0;y<v.length;y++)v[y]===0&&(v[y]=g[T++]);if(T!==g.length)throw new Error("the unsqueezed dimension could not be established");return v}}e.ShapeUtil=i,e.MathUtil=class{static sqr(m,g,b,v,T){if(v<0||v>=g.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(v+T>g.length)throw new Error("source indices to be copied are outside bounds");if(b+T>m.length)throw new Error("target array is too small to hold result");for(let y=0;y<T;y++)m[b+y]+=Math.pow(g[v+y],2)}static axpy(m,g,b,v,T,y){if(v<0||v>=g.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(v+T>g.length)throw new Error("source indices to be copied are outside bounds");if(b+T>m.length)throw new Error("target array is too small to hold result");for(let w=0;w<T;w++)m[b+w]+=y*g[v+w]}static powx(m,g,b,v,T,y){if(v<0||v>=g.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(v+T>g.length)throw new Error("source indices to be copied are outside bounds");if(b+T>m.length)throw new Error("target array is too small to hold result");for(let w=0;w<T;w++)m[b+w]=Math.pow(g[v+w],y)}static mul(m,g,b,v,T){if(v<0||v>=g.length)throw new Error("sourceIndex out of bounds");if(b<0||b>=m.length)throw new Error("targetIndex out of bounds");if(v+T>g.length)throw new Error("source indices to be copied are outside bounds");if(b+T>m.length)throw new Error("target array is too small to hold result");for(let y=0;y<T;y++)m[b+y]=g[v+y]*m[b+y]}};class d{static splitShape(g,b,v,T){if(v.length===0){if(!T)throw new Error("need to know number of outputs when the 'split' attribute is not specified");d.determineSplit(g[b],T,v)}const y=[],w=[0];for(let S=0;S<v.length;++S){S!==0&&w.push(w[S-1]+v[S-1]);const O=g.slice();O[b]=v[S],y.push(O)}return[y,w]}static determineSplit(g,b,v){if(g%b!=0)throw new Error("cannot split tensor to equal sized parts");for(let T=0;T<b;++T)v.push(g/b)}}e.SplitUtil=d;class p{static calcReduce(g,b,v,T,y){const w=g.dims.slice(0);b.length===0&&w.forEach((k,D)=>b.push(D));const S=p.calcReduceShape(w,b,!0),O=i.size(S),P=new l.Tensor(S,g.type),E=i.computeStrides(S),A=i.computeStrides(w),$=new Array(w.length);for(let k=0;k<O;k++){const D=i.offsetToIndices(k,E);f.fillIndex(D,w,$),P.set(D,p.calcReduceByAxis(g.numberData,b,w,0,i.indicesToOffset($,A),T,y))}return v?P:new l.Tensor(p.calcReduceShape(w,b,v),P.type,void 0,void 0,P.data,P.dataId)}static calcReduceByAxis(g,b,v,T,y,w,S){let O=0;if(T>=b.length)return w(g[y]);const P=b[T],E=P>=v.length?1:i.size(v.slice(P+1));for(let A=0;A<v[P];A++)O=A===0?p.calcReduceByAxis(g,b,v,T+1,y,w,S):S(O,p.calcReduceByAxis(g,b,v,T+1,y,w,S)),y+=E;return O}static calcReduceShape(g,b,v){const T=g.slice();for(let y=0;y<b.length;y++)T[b[y]]=v?1:0;return T.filter(y=>y!==0)}}e.ReduceUtil=p;class _{static adjustPoolAttributes(g,b,v,T,y,w){if(!g&&v.length!==b.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(g)for(let S=0;S<b.length-2;S++)S>=v.length?v.push(b[S+2]):v[S]=b[S+2];for(let S=0;S<v.length;S++)if(S<T.length){if(T[S]<0)throw new Error("strides should be greater than or equal to 1")}else T.push(1);for(let S=0;S<v.length;S++)if(S<y.length){if(y[S]<0)throw new Error("dilations should be greater than or equal to 1")}else y.push(1);for(let S=0;S<2*v.length;S++)if(S<w.length){if(w[S]<0)throw new Error("pad should be greater than or equal to 1")}else w.push(0);for(let S=0;S<v.length;S++){if(v[S]<=0)throw new Error("kernel shapes need to be greater than 0");if(w[S]>=v[S]||w[S+v.length]>=v[S])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(g,b,v,T,y,w){if(w){if(y.length!==2*(g.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(b.length!==g.length-2)throw new Error("length of strides should be the length of data dimensions");if(T.length!==g.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let S=0;S<g.length-2;S++)_.adjustPadAndReturnShape(g[S+2],b[S],v[S],T[S],y,S,S+g.length-2,w)}}static computePoolOutputShape(g,b,v,T,y,w,S){if(b.length<=0)throw new Error("input shape must be of size greater than 0");const O=[b[0],b[1]];return _.computeShapeHelper(g,b,O,v,T,y,w,S),O}static computeConvOutputShape(g,b,v,T,y,w,S){if(g.length<=0||b.length<=0)throw new Error("invalid input tensor dims or invalid filter tensor dims");const O=[g[0],b[0]];return _.computeShapeHelper(!1,g,O,v,T,y,w,S),O}static computeShapeHelper(g,b,v,T,y,w,S,O){if(g)for(let P=0;P<b.length-2;P++)v.push(1);else for(let P=0;P<b.length-2;P++)v.push(_.adjustPadAndReturnShape(b[P+2],T[P],y[P],w[P],S,P,P+b.length-2,O))}static adjustPadAndReturnShape(g,b,v,T,y,w,S,O){const P=v*(T-1)+1;if(!O||O==="NOTSET")return Math.floor((g+y[w]+y[S]-P)/b+1);switch(O){case"VALID":return y[w]=0,y[S]=0,Math.floor((g-P)/b+1);case"SAME_LOWER":case"SAME_UPPER":if(v!==1)throw new Error("Dilation not supported for SAME_UPPER or SAME_LOWER");{const E=((g+b-1)/b-1)*b+T-g;return y[w]=Math.floor(O==="SAME_LOWER"?(E+1)/2:E/2),y[S]=E-y[w],Math.floor((g+E-T)/b+1)}default:throw new Error("Unsupported AutoPad type")}}}e.PoolConvUtil=_,e.MIN_CLIP=-34028234663852886e22,e.MAX_CLIP=34028234663852886e22,e.decodeUtf8String=function(m){return new TextDecoder().decode(m)}},8408:(a,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.version=void 0,e.version="1.16.3"},9544:function(a,e,n){var t,r=this&&this.__createBinding||(Object.create?function(E,A,$,k){k===void 0&&(k=$);var D=Object.getOwnPropertyDescriptor(A,$);D&&!("get"in D?!A.__esModule:D.writable||D.configurable)||(D={enumerable:!0,get:function(){return A[$]}}),Object.defineProperty(E,k,D)}:function(E,A,$,k){k===void 0&&(k=$),E[k]=A[$]}),o=this&&this.__setModuleDefault||(Object.create?function(E,A){Object.defineProperty(E,"default",{enumerable:!0,value:A})}:function(E,A){E.default=A}),s=this&&this.__importStar||function(E){if(E&&E.__esModule)return E;var A={};if(E!=null)for(var $ in E)$!=="default"&&Object.prototype.hasOwnProperty.call(E,$)&&r(A,E,$);return o(A,E),A};Object.defineProperty(e,"__esModule",{value:!0}),e.endProfiling=e.run=e.releaseSession=e.createSession=e.createSessionFinalize=e.createSessionAllocate=e.initializeRuntime=e.initializeWebAssemblyInstance=void 0;const l=n(2235),c=s(n(1259)),f=n(263),h=()=>!!l.env.wasm.proxy&&typeof document<"u";let u,i,d,p=!1,_=!1,m=!1;const g=[],b=[],v=[],T=[],y=[],w=[],S=()=>{if(p||!_||m||!u)throw new Error("worker not ready")},O=E=>{switch(E.data.type){case"init-wasm":p=!1,E.data.err?(m=!0,i[1](E.data.err)):(_=!0,i[0]());break;case"init-ort":E.data.err?d[1](E.data.err):d[0]();break;case"create_allocate":E.data.err?g.shift()[1](E.data.err):g.shift()[0](E.data.out);break;case"create_finalize":E.data.err?b.shift()[1](E.data.err):b.shift()[0](E.data.out);break;case"create":E.data.err?v.shift()[1](E.data.err):v.shift()[0](E.data.out);break;case"release":E.data.err?T.shift()[1](E.data.err):T.shift()[0]();break;case"run":E.data.err?y.shift()[1](E.data.err):y.shift()[0](E.data.out);break;case"end-profiling":E.data.err?w.shift()[1](E.data.err):w.shift()[0]()}},P=typeof document<"u"?(t=document==null?void 0:document.currentScript)===null||t===void 0?void 0:t.src:void 0;e.initializeWebAssemblyInstance=async()=>{if(h()){if(_)return;if(p)throw new Error("multiple calls to 'initWasm()' detected.");if(m)throw new Error("previous call to 'initWasm()' failed.");return p=!0,l.env.wasm.wasmPaths===void 0&&P&&P.indexOf("blob:")!==0&&(l.env.wasm.wasmPaths=P.substr(0,+P.lastIndexOf("/")+1)),new Promise((E,A)=>{u==null||u.terminate(),u=n(8050).Z(),u.onmessage=O,i=[E,A];const $={type:"init-wasm",in:l.env.wasm};u.postMessage($)})}return(0,f.initializeWebAssembly)(l.env.wasm)},e.initializeRuntime=async E=>{if(h())return S(),new Promise((A,$)=>{d=[A,$];const k={type:"init-ort",in:E};u.postMessage(k)});await c.initRuntime(E)},e.createSessionAllocate=async E=>h()?(S(),new Promise((A,$)=>{g.push([A,$]);const k={type:"create_allocate",in:{model:E}};u.postMessage(k,[E.buffer])})):c.createSessionAllocate(E),e.createSessionFinalize=async(E,A)=>h()?(S(),new Promise(($,k)=>{b.push([$,k]);const D={type:"create_finalize",in:{modeldata:E,options:A}};u.postMessage(D)})):c.createSessionFinalize(E,A),e.createSession=async(E,A)=>h()?(S(),new Promise(($,k)=>{v.push([$,k]);const D={type:"create",in:{model:E,options:A}};u.postMessage(D,[E.buffer])})):c.createSession(E,A),e.releaseSession=async E=>{if(h())return S(),new Promise((A,$)=>{T.push([A,$]);const k={type:"release",in:E};u.postMessage(k)});c.releaseSession(E)},e.run=async(E,A,$,k,D)=>h()?(S(),new Promise((I,C)=>{y.push([I,C]);const L={type:"run",in:{sessionId:E,inputIndices:A,inputs:$,outputIndices:k,options:D}};u.postMessage(L,c.extractTransferableBuffers($))})):c.run(E,A,$,k,D),e.endProfiling=async E=>{if(h())return S(),new Promise((A,$)=>{w.push([A,$]);const k={type:"end-profiling",in:E};u.postMessage(k)});c.endProfiling(E)}},7918:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.setRunOptions=void 0;const t=n(263),r=n(1497);e.setRunOptions=o=>{const s=(0,t.getInstance)();let l=0;const c=[],f=o||{};try{if((o==null?void 0:o.logSeverityLevel)===void 0)f.logSeverityLevel=2;else if(typeof o.logSeverityLevel!="number"||!Number.isInteger(o.logSeverityLevel)||o.logSeverityLevel<0||o.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${o.logSeverityLevel}`);if((o==null?void 0:o.logVerbosityLevel)===void 0)f.logVerbosityLevel=0;else if(typeof o.logVerbosityLevel!="number"||!Number.isInteger(o.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${o.logVerbosityLevel}`);(o==null?void 0:o.terminate)===void 0&&(f.terminate=!1);let h=0;return(o==null?void 0:o.tag)!==void 0&&(h=(0,r.allocWasmString)(o.tag,c)),l=s._OrtCreateRunOptions(f.logSeverityLevel,f.logVerbosityLevel,!!f.terminate,h),l===0&&(0,r.checkLastError)("Can't create run options."),(o==null?void 0:o.extra)!==void 0&&(0,r.iterateExtraOptions)(o.extra,"",new WeakSet,(u,i)=>{const d=(0,r.allocWasmString)(u,c),p=(0,r.allocWasmString)(i,c);s._OrtAddRunConfigEntry(l,d,p)!==0&&(0,r.checkLastError)(`Can't set a run config entry: ${u} - ${i}.`)}),[l,c]}catch(h){throw l!==0&&s._OrtReleaseRunOptions(l),c.forEach(u=>s._free(u)),h}}},6640:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OnnxruntimeWebAssemblySessionHandler=void 0;const t=n(2806),r=n(2235),o=n(2850),s=n(9544);let l;e.OnnxruntimeWebAssemblySessionHandler=class{async createSessionAllocate(c){const f=await fetch(c);if(f.status!==200)throw new Error(`failed to load model: ${c}`);const h=await f.arrayBuffer();return(0,s.createSessionAllocate)(new Uint8Array(h))}async loadModel(c,f){if(l||(await(0,s.initializeRuntime)(r.env),l=!0),typeof c=="string")if(typeof process<"u"&&process.versions&&process.versions.node){const h=await(0,o.promisify)(t.readFile)(c);[this.sessionId,this.inputNames,this.outputNames]=await(0,s.createSession)(h,f)}else{const h=await this.createSessionAllocate(c);[this.sessionId,this.inputNames,this.outputNames]=await(0,s.createSessionFinalize)(h,f)}else[this.sessionId,this.inputNames,this.outputNames]=await(0,s.createSession)(c,f)}async dispose(){return(0,s.releaseSession)(this.sessionId)}async run(c,f,h){const u=[],i=[];Object.entries(c).forEach(m=>{const g=m[0],b=m[1],v=this.inputNames.indexOf(g);if(v===-1)throw new Error(`invalid input '${g}'`);u.push(b),i.push(v)});const d=[];Object.entries(f).forEach(m=>{const g=m[0],b=this.outputNames.indexOf(g);if(b===-1)throw new Error(`invalid output '${g}'`);d.push(b)});const p=await(0,s.run)(this.sessionId,i,u.map(m=>[m.type,m.dims,m.data]),d,h),_={};for(let m=0;m<p.length;m++)_[this.outputNames[d[m]]]=new r.Tensor(p[m][0],p[m][2],p[m][1]);return _}startProfiling(){}endProfiling(){(0,s.endProfiling)(this.sessionId)}}},7622:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.setSessionOptions=void 0;const t=n(263),r=n(1497);e.setSessionOptions=o=>{var s,l,c,f;const h=(0,t.getInstance)();let u=0;const i=[],d=o||{};(p=>{p.extra||(p.extra={}),p.extra.session||(p.extra.session={});const _=p.extra.session;_.use_ort_model_bytes_directly||(_.use_ort_model_bytes_directly="1"),p.executionProviders&&p.executionProviders.some(m=>(typeof m=="string"?m:m.name)==="webgpu")&&(p.enableMemPattern=!1)})(d);try{const p=(T=>{switch(T){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${T}`)}})((s=d.graphOptimizationLevel)!==null&&s!==void 0?s:"all"),_=(T=>{switch(T){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${T}`)}})((l=d.executionMode)!==null&&l!==void 0?l:"sequential"),m=typeof d.logId=="string"?(0,r.allocWasmString)(d.logId,i):0,g=(c=d.logSeverityLevel)!==null&&c!==void 0?c:2;if(!Number.isInteger(g)||g<0||g>4)throw new Error(`log serverity level is not valid: ${g}`);const b=(f=d.logVerbosityLevel)!==null&&f!==void 0?f:0;if(!Number.isInteger(b)||b<0||b>4)throw new Error(`log verbosity level is not valid: ${b}`);const v=typeof d.optimizedModelFilePath=="string"?(0,r.allocWasmString)(d.optimizedModelFilePath,i):0;return u=h._OrtCreateSessionOptions(p,!!d.enableCpuMemArena,!!d.enableMemPattern,_,!!d.enableProfiling,0,m,g,b,v),u===0&&(0,r.checkLastError)("Can't create session options."),d.executionProviders&&((T,y,w)=>{for(const S of y){let O=typeof S=="string"?S:S.name;switch(O){case"xnnpack":O="XNNPACK";break;case"webnn":if(O="WEBNN",typeof S!="string"){const E=S;if(E!=null&&E.deviceType){const A=(0,r.allocWasmString)("deviceType",w),$=(0,r.allocWasmString)(E.deviceType,w);(0,t.getInstance)()._OrtAddSessionConfigEntry(T,A,$)!==0&&(0,r.checkLastError)(`Can't set a session config entry: 'deviceType' - ${E.deviceType}.`)}if(E!=null&&E.powerPreference){const A=(0,r.allocWasmString)("powerPreference",w),$=(0,r.allocWasmString)(E.powerPreference,w);(0,t.getInstance)()._OrtAddSessionConfigEntry(T,A,$)!==0&&(0,r.checkLastError)(`Can't set a session config entry: 'powerPreference' - ${E.powerPreference}.`)}}break;case"webgpu":O="JS";break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${O}`)}const P=(0,r.allocWasmString)(O,w);(0,t.getInstance)()._OrtAppendExecutionProvider(T,P)!==0&&(0,r.checkLastError)(`Can't append execution provider: ${O}.`)}})(u,d.executionProviders,i),d.extra!==void 0&&(0,r.iterateExtraOptions)(d.extra,"",new WeakSet,(T,y)=>{const w=(0,r.allocWasmString)(T,i),S=(0,r.allocWasmString)(y,i);h._OrtAddSessionConfigEntry(u,w,S)!==0&&(0,r.checkLastError)(`Can't set a session config entry: ${T} - ${y}.`)}),[u,i]}catch(p){throw u!==0&&h._OrtReleaseSessionOptions(u),i.forEach(_=>h._free(_)),p}}},7917:(a,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.logLevelStringToEnum=e.tensorTypeToTypedArrayConstructor=e.getTensorElementSize=e.tensorDataTypeEnumToString=e.tensorDataTypeStringToEnum=void 0,e.tensorDataTypeStringToEnum=n=>{switch(n){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${n}`)}},e.tensorDataTypeEnumToString=n=>{switch(n){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${n}`)}},e.getTensorElementSize=n=>[void 0,4,1,1,2,2,4,8,void 0,1,2,8,4,8,void 0,void 0,void 0][n],e.tensorTypeToTypedArrayConstructor=n=>{switch(n){case"float16":case"uint16":return Uint16Array;case"float32":return Float32Array;case"uint8":case"bool":return Uint8Array;case"int8":return Int8Array;case"int16":return Int16Array;case"int32":return Int32Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${n}`)}},e.logLevelStringToEnum=n=>{switch(n){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${n}`)}}},1259:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extractTransferableBuffers=e.endProfiling=e.run=e.releaseSession=e.createSession=e.createSessionFinalize=e.createSessionAllocate=e.initRuntime=void 0;const t=n(7918),r=n(7622),o=n(7917),s=n(263),l=n(1497);e.initRuntime=async f=>{var h,u;h=f.wasm.numThreads,u=(0,o.logLevelStringToEnum)(f.logLevel),(0,s.getInstance)()._OrtInit(h,u)!==0&&(0,l.checkLastError)("Can't initialize onnxruntime.")};const c=new Map;e.createSessionAllocate=f=>{const h=(0,s.getInstance)(),u=h._malloc(f.byteLength);if(u===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${f.byteLength}.`);return h.HEAPU8.set(f,u),[u,f.byteLength]},e.createSessionFinalize=(f,h)=>{const u=(0,s.getInstance)();let i=0,d=0,p=[];const _=[],m=[];try{[d,p]=(0,r.setSessionOptions)(h),i=u._OrtCreateSession(f[0],f[1],d),i===0&&(0,l.checkLastError)("Can't create a session.");const[g,b]=(y=>{const w=(0,s.getInstance)(),S=w.stackSave();try{const O=w.stackAlloc(8);return w._OrtGetInputOutputCount(y,O,O+4)!==0&&(0,l.checkLastError)("Can't get session input/output count."),[w.HEAP32[O/4],w.HEAP32[O/4+1]]}finally{w.stackRestore(S)}})(i),v=[],T=[];for(let y=0;y<g;y++){const w=u._OrtGetInputName(i,y);w===0&&(0,l.checkLastError)("Can't get an input name."),_.push(w),v.push(u.UTF8ToString(w))}for(let y=0;y<b;y++){const w=u._OrtGetOutputName(i,y);w===0&&(0,l.checkLastError)("Can't get an output name."),m.push(w),T.push(u.UTF8ToString(w))}return c.set(i,[i,_,m]),[i,v,T]}catch(g){throw _.forEach(b=>u._OrtFree(b)),m.forEach(b=>u._OrtFree(b)),i!==0&&u._OrtReleaseSession(i),g}finally{u._free(f[0]),d!==0&&u._OrtReleaseSessionOptions(d),p.forEach(g=>u._free(g))}},e.createSession=(f,h)=>{const u=(0,e.createSessionAllocate)(f);return(0,e.createSessionFinalize)(u,h)},e.releaseSession=f=>{const h=(0,s.getInstance)(),u=c.get(f);if(!u)throw new Error(`cannot release session. invalid session id: ${f}`);const[i,d,p]=u;d.forEach(_=>h._OrtFree(_)),p.forEach(_=>h._OrtFree(_)),h._OrtReleaseSession(i),c.delete(f)},e.run=async(f,h,u,i,d)=>{const p=(0,s.getInstance)(),_=c.get(f);if(!_)throw new Error(`cannot run inference. invalid session id: ${f}`);const[m,g,b]=_,v=h.length,T=i.length;let y=0,w=[];const S=[],O=[];try{[y,w]=(0,t.setRunOptions)(d);for(let D=0;D<v;D++){const I=u[D][0],C=u[D][1],L=u[D][2];let K,G;if(Array.isArray(L)){G=4*L.length,K=p._malloc(G),O.push(K);let te=K/4;for(let ee=0;ee<L.length;ee++){if(typeof L[ee]!="string")throw new TypeError(`tensor data at index ${ee} is not a string`);p.HEAPU32[te++]=(0,l.allocWasmString)(L[ee],O)}}else G=L.byteLength,K=p._malloc(G),O.push(K),p.HEAPU8.set(new Uint8Array(L.buffer,L.byteOffset,G),K);const J=p.stackSave(),Y=p.stackAlloc(4*C.length);try{let te=Y/4;C.forEach(ie=>p.HEAP32[te++]=ie);const ee=p._OrtCreateTensor((0,o.tensorDataTypeStringToEnum)(I),K,G,Y,C.length);ee===0&&(0,l.checkLastError)(`Can't create tensor for input[${D}].`),S.push(ee)}finally{p.stackRestore(J)}}const P=p.stackSave(),E=p.stackAlloc(4*v),A=p.stackAlloc(4*v),$=p.stackAlloc(4*T),k=p.stackAlloc(4*T);try{let D=E/4,I=A/4,C=$/4,L=k/4;for(let Y=0;Y<v;Y++)p.HEAPU32[D++]=S[Y],p.HEAPU32[I++]=g[h[Y]];for(let Y=0;Y<T;Y++)p.HEAPU32[C++]=0,p.HEAPU32[L++]=b[i[Y]];let K=p._OrtRun(m,A,E,v,k,T,$,y);const G=p.jsepRunPromise;G&&G.then!==void 0&&(K=await G);const J=[];K!==0&&(0,l.checkLastError)("failed to call OrtRun().");for(let Y=0;Y<T;Y++){const te=p.HEAPU32[$/4+Y],ee=p.stackSave(),ie=p.stackAlloc(16);let ae,ue=0;try{K=p._OrtGetTensorData(te,ie,ie+4,ie+8,ie+12),K!==0&&(0,l.checkLastError)(`Can't access output tensor data on index ${Y}.`);let fe=ie/4;const ge=p.HEAPU32[fe++];ue=p.HEAPU32[fe++];const be=p.HEAPU32[fe++],xe=p.HEAPU32[fe++],ve=[];for(let pe=0;pe<xe;pe++)ve.push(p.HEAPU32[be/4+pe]);p._OrtFree(be);const Te=ve.length===0?1:ve.reduce((pe,ke)=>pe*ke);if(ae=(0,o.tensorDataTypeEnumToString)(ge),ae==="string"){const pe=[];let ke=ue/4;for(let Pe=0;Pe<Te;Pe++){const Ie=p.HEAPU32[ke++],Ce=Pe===Te-1?void 0:p.HEAPU32[ke]-Ie;pe.push(p.UTF8ToString(Ie,Ce))}J.push([ae,ve,pe])}else{const pe=new((0,o.tensorTypeToTypedArrayConstructor)(ae))(Te);new Uint8Array(pe.buffer,pe.byteOffset,pe.byteLength).set(p.HEAPU8.subarray(ue,ue+pe.byteLength)),J.push([ae,ve,pe])}}finally{p.stackRestore(ee),ae==="string"&&ue&&p._free(ue),p._OrtReleaseTensor(te)}}return J}finally{p.stackRestore(P)}}finally{S.forEach(P=>p._OrtReleaseTensor(P)),O.forEach(P=>p._free(P)),y!==0&&p._OrtReleaseRunOptions(y),w.forEach(P=>p._free(P))}},e.endProfiling=f=>{const h=(0,s.getInstance)(),u=c.get(f);if(!u)throw new Error("invalid session id");const i=u[0],d=h._OrtEndProfiling(i);d===0&&(0,l.checkLastError)("Can't get an profile file name."),h._OrtFree(d)},e.extractTransferableBuffers=f=>{const h=[];for(const u of f){const i=u[2];!Array.isArray(i)&&i.buffer&&h.push(i.buffer)}return h}},263:function(a,e,n){var t=this&&this.__createBinding||(Object.create?function(d,p,_,m){m===void 0&&(m=_);var g=Object.getOwnPropertyDescriptor(p,_);g&&!("get"in g?!p.__esModule:g.writable||g.configurable)||(g={enumerable:!0,get:function(){return p[_]}}),Object.defineProperty(d,m,g)}:function(d,p,_,m){m===void 0&&(m=_),d[m]=p[_]}),r=this&&this.__setModuleDefault||(Object.create?function(d,p){Object.defineProperty(d,"default",{enumerable:!0,value:p})}:function(d,p){d.default=p}),o=this&&this.__importStar||function(d){if(d&&d.__esModule)return d;var p={};if(d!=null)for(var _ in d)_!=="default"&&Object.prototype.hasOwnProperty.call(d,_)&&t(p,d,_);return r(p,d),p};Object.defineProperty(e,"__esModule",{value:!0}),e.dispose=e.getInstance=e.initializeWebAssembly=void 0;const s=o(n(6449)),l=n(932),c=n(3474);let f,h=!1,u=!1,i=!1;e.initializeWebAssembly=async d=>{if(h)return Promise.resolve();if(u)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(i)throw new Error("previous call to 'initializeWebAssembly()' failed.");u=!0;const p=d.initTimeout,_=d.numThreads,m=d.simd,g=_>1&&(()=>{try{return typeof SharedArrayBuffer<"u"&&(typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])))}catch{return!1}})(),b=m&&(()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}})(),v=d.wasmPaths,T=typeof v=="string"?v:void 0,y=((P,E)=>E?P?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":P?"ort-wasm-simd.wasm":"ort-wasm.wasm")(b,g),w=typeof v=="object"?v[y]:void 0;let S=!1;const O=[];if(p>0&&O.push(new Promise(P=>{setTimeout(()=>{S=!0,P()},p)})),O.push(new Promise((P,E)=>{const A=g?c:l,$={locateFile:(k,D)=>g&&k.endsWith(".worker.js")&&typeof Blob<"u"?URL.createObjectURL(new Blob([n(4154)],{type:"text/javascript"})):k.endsWith(".wasm")?w||(T??D)+y:D+k};if(g)if(typeof Blob>"u")$.mainScriptUrlOrBlob=s.join(__dirname,"ort-wasm-threaded.js");else{const k=`var ortWasmThreaded=(function(){var _scriptDir;return ${A.toString()}})();`;$.mainScriptUrlOrBlob=new Blob([k],{type:"text/javascript"})}A($).then(k=>{u=!1,h=!0,f=k,P()},k=>{u=!1,i=!0,E(k)})})),await Promise.race(O),S)throw new Error(`WebAssembly backend initializing failed due to timeout: ${p}ms`)},e.getInstance=()=>{if(h&&f)return f;throw new Error("WebAssembly is not initialized yet.")},e.dispose=()=>{var d;!h||u||i||(u=!0,(d=f.PThread)===null||d===void 0||d.terminateAllThreads(),f=void 0,u=!1,h=!1,i=!0)}},1497:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.checkLastError=e.iterateExtraOptions=e.allocWasmString=void 0;const t=n(263);e.allocWasmString=(r,o)=>{const s=(0,t.getInstance)(),l=s.lengthBytesUTF8(r)+1,c=s._malloc(l);return s.stringToUTF8(r,c,l),o.push(c),c},e.iterateExtraOptions=(r,o,s,l)=>{if(typeof r=="object"&&r!==null){if(s.has(r))throw new Error("Circular reference in options");s.add(r)}Object.entries(r).forEach(([c,f])=>{const h=o?o+c:c;if(typeof f=="object")(0,e.iterateExtraOptions)(f,h+".",s,l);else if(typeof f=="string"||typeof f=="number")l(h,f.toString());else{if(typeof f!="boolean")throw new Error("Can't handle extra config type: "+typeof f);l(h,f?"1":"0")}})},e.checkLastError=r=>{const o=(0,t.getInstance)(),s=o.stackSave();try{const l=o.stackAlloc(8);o._OrtGetLastError(l,l+4);const c=o.HEAP32[l/4],f=o.HEAPU32[l/4+1],h=f?o.UTF8ToString(f):"";throw new Error(`${r} ERROR_CODE: ${c}, ERROR_MESSAGE: ${h}`)}finally{o.stackRestore(s)}}},8050:(a,e,n)=>{n.d(e,{Z:()=>o});var t=n(6614),r=n.n(t);function o(){return r()('/*!\n* ONNX Runtime Web v1.16.3\n* Copyright (c) Microsoft Corporation. All rights reserved.\n* Licensed under the MIT License.\n*/\n(()=>{var e={918:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setRunOptions=void 0;const n=r(263),a=r(497);t.setRunOptions=e=>{const t=(0,n.getInstance)();let r=0;const o=[],i=e||{};try{if(void 0===(null==e?void 0:e.logSeverityLevel))i.logSeverityLevel=2;else if("number"!=typeof e.logSeverityLevel||!Number.isInteger(e.logSeverityLevel)||e.logSeverityLevel<0||e.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${e.logSeverityLevel}`);if(void 0===(null==e?void 0:e.logVerbosityLevel))i.logVerbosityLevel=0;else if("number"!=typeof e.logVerbosityLevel||!Number.isInteger(e.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${e.logVerbosityLevel}`);void 0===(null==e?void 0:e.terminate)&&(i.terminate=!1);let n=0;return void 0!==(null==e?void 0:e.tag)&&(n=(0,a.allocWasmString)(e.tag,o)),r=t._OrtCreateRunOptions(i.logSeverityLevel,i.logVerbosityLevel,!!i.terminate,n),0===r&&(0,a.checkLastError)("Can\'t create run options."),void 0!==(null==e?void 0:e.extra)&&(0,a.iterateExtraOptions)(e.extra,"",new WeakSet,((e,n)=>{const i=(0,a.allocWasmString)(e,o),s=(0,a.allocWasmString)(n,o);0!==t._OrtAddRunConfigEntry(r,i,s)&&(0,a.checkLastError)(`Can\'t set a run config entry: ${e} - ${n}.`)})),[r,o]}catch(e){throw 0!==r&&t._OrtReleaseRunOptions(r),o.forEach((e=>t._free(e))),e}}},622:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setSessionOptions=void 0;const n=r(263),a=r(497);t.setSessionOptions=e=>{var t,r,o,i;const s=(0,n.getInstance)();let u=0;const c=[],l=e||{};(e=>{e.extra||(e.extra={}),e.extra.session||(e.extra.session={});const t=e.extra.session;t.use_ort_model_bytes_directly||(t.use_ort_model_bytes_directly="1"),e.executionProviders&&e.executionProviders.some((e=>"webgpu"===("string"==typeof e?e:e.name)))&&(e.enableMemPattern=!1)})(l);try{const e=(e=>{switch(e){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${e}`)}})(null!==(t=l.graphOptimizationLevel)&&void 0!==t?t:"all"),f=(e=>{switch(e){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${e}`)}})(null!==(r=l.executionMode)&&void 0!==r?r:"sequential"),d="string"==typeof l.logId?(0,a.allocWasmString)(l.logId,c):0,p=null!==(o=l.logSeverityLevel)&&void 0!==o?o:2;if(!Number.isInteger(p)||p<0||p>4)throw new Error(`log serverity level is not valid: ${p}`);const g=null!==(i=l.logVerbosityLevel)&&void 0!==i?i:0;if(!Number.isInteger(g)||g<0||g>4)throw new Error(`log verbosity level is not valid: ${g}`);const h="string"==typeof l.optimizedModelFilePath?(0,a.allocWasmString)(l.optimizedModelFilePath,c):0;return u=s._OrtCreateSessionOptions(e,!!l.enableCpuMemArena,!!l.enableMemPattern,f,!!l.enableProfiling,0,d,p,g,h),0===u&&(0,a.checkLastError)("Can\'t create session options."),l.executionProviders&&((e,t,r)=>{for(const o of t){let t="string"==typeof o?o:o.name;switch(t){case"xnnpack":t="XNNPACK";break;case"webnn":if(t="WEBNN","string"!=typeof o){const t=o;if(null==t?void 0:t.deviceType){const o=(0,a.allocWasmString)("deviceType",r),i=(0,a.allocWasmString)(t.deviceType,r);0!==(0,n.getInstance)()._OrtAddSessionConfigEntry(e,o,i)&&(0,a.checkLastError)(`Can\'t set a session config entry: \'deviceType\' - ${t.deviceType}.`)}if(null==t?void 0:t.powerPreference){const o=(0,a.allocWasmString)("powerPreference",r),i=(0,a.allocWasmString)(t.powerPreference,r);0!==(0,n.getInstance)()._OrtAddSessionConfigEntry(e,o,i)&&(0,a.checkLastError)(`Can\'t set a session config entry: \'powerPreference\' - ${t.powerPreference}.`)}}break;case"webgpu":t="JS";break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${t}`)}const i=(0,a.allocWasmString)(t,r);0!==(0,n.getInstance)()._OrtAppendExecutionProvider(e,i)&&(0,a.checkLastError)(`Can\'t append execution provider: ${t}.`)}})(u,l.executionProviders,c),void 0!==l.extra&&(0,a.iterateExtraOptions)(l.extra,"",new WeakSet,((e,t)=>{const r=(0,a.allocWasmString)(e,c),n=(0,a.allocWasmString)(t,c);0!==s._OrtAddSessionConfigEntry(u,r,n)&&(0,a.checkLastError)(`Can\'t set a session config entry: ${e} - ${t}.`)})),[u,c]}catch(e){throw 0!==u&&s._OrtReleaseSessionOptions(u),c.forEach((e=>s._free(e))),e}}},917:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logLevelStringToEnum=t.tensorTypeToTypedArrayConstructor=t.getTensorElementSize=t.tensorDataTypeEnumToString=t.tensorDataTypeStringToEnum=void 0,t.tensorDataTypeStringToEnum=e=>{switch(e){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${e}`)}},t.tensorDataTypeEnumToString=e=>{switch(e){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${e}`)}},t.getTensorElementSize=e=>[void 0,4,1,1,2,2,4,8,void 0,1,2,8,4,8,void 0,void 0,void 0][e],t.tensorTypeToTypedArrayConstructor=e=>{switch(e){case"float16":case"uint16":return Uint16Array;case"float32":return Float32Array;case"uint8":case"bool":return Uint8Array;case"int8":return Int8Array;case"int16":return Int16Array;case"int32":return Int32Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${e}`)}},t.logLevelStringToEnum=e=>{switch(e){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${e}`)}}},259:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractTransferableBuffers=t.endProfiling=t.run=t.releaseSession=t.createSession=t.createSessionFinalize=t.createSessionAllocate=t.initRuntime=void 0;const n=r(918),a=r(622),o=r(917),i=r(263),s=r(497);t.initRuntime=async e=>{var t,r;t=e.wasm.numThreads,r=(0,o.logLevelStringToEnum)(e.logLevel),0!==(0,i.getInstance)()._OrtInit(t,r)&&(0,s.checkLastError)("Can\'t initialize onnxruntime.")};const u=new Map;t.createSessionAllocate=e=>{const t=(0,i.getInstance)(),r=t._malloc(e.byteLength);if(0===r)throw new Error(`Can\'t create a session. failed to allocate a buffer of size ${e.byteLength}.`);return t.HEAPU8.set(e,r),[r,e.byteLength]},t.createSessionFinalize=(e,t)=>{const r=(0,i.getInstance)();let n=0,o=0,c=[];const l=[],f=[];try{[o,c]=(0,a.setSessionOptions)(t),n=r._OrtCreateSession(e[0],e[1],o),0===n&&(0,s.checkLastError)("Can\'t create a session.");const[d,p]=(e=>{const t=(0,i.getInstance)(),r=t.stackSave();try{const r=t.stackAlloc(8);return 0!==t._OrtGetInputOutputCount(e,r,r+4)&&(0,s.checkLastError)("Can\'t get session input/output count."),[t.HEAP32[r/4],t.HEAP32[r/4+1]]}finally{t.stackRestore(r)}})(n),g=[],h=[];for(let e=0;e<d;e++){const t=r._OrtGetInputName(n,e);0===t&&(0,s.checkLastError)("Can\'t get an input name."),l.push(t),g.push(r.UTF8ToString(t))}for(let e=0;e<p;e++){const t=r._OrtGetOutputName(n,e);0===t&&(0,s.checkLastError)("Can\'t get an output name."),f.push(t),h.push(r.UTF8ToString(t))}return u.set(n,[n,l,f]),[n,g,h]}catch(e){throw l.forEach((e=>r._OrtFree(e))),f.forEach((e=>r._OrtFree(e))),0!==n&&r._OrtReleaseSession(n),e}finally{r._free(e[0]),0!==o&&r._OrtReleaseSessionOptions(o),c.forEach((e=>r._free(e)))}},t.createSession=(e,r)=>{const n=(0,t.createSessionAllocate)(e);return(0,t.createSessionFinalize)(n,r)},t.releaseSession=e=>{const t=(0,i.getInstance)(),r=u.get(e);if(!r)throw new Error(`cannot release session. invalid session id: ${e}`);const[n,a,o]=r;a.forEach((e=>t._OrtFree(e))),o.forEach((e=>t._OrtFree(e))),t._OrtReleaseSession(n),u.delete(e)},t.run=async(e,t,r,a,c)=>{const l=(0,i.getInstance)(),f=u.get(e);if(!f)throw new Error(`cannot run inference. invalid session id: ${e}`);const[d,p,g]=f,h=t.length,m=a.length;let y=0,v=[];const b=[],w=[];try{[y,v]=(0,n.setRunOptions)(c);for(let e=0;e<h;e++){const t=r[e][0],n=r[e][1],a=r[e][2];let i,u;if(Array.isArray(a)){u=4*a.length,i=l._malloc(u),w.push(i);let e=i/4;for(let t=0;t<a.length;t++){if("string"!=typeof a[t])throw new TypeError(`tensor data at index ${t} is not a string`);l.HEAPU32[e++]=(0,s.allocWasmString)(a[t],w)}}else u=a.byteLength,i=l._malloc(u),w.push(i),l.HEAPU8.set(new Uint8Array(a.buffer,a.byteOffset,u),i);const c=l.stackSave(),f=l.stackAlloc(4*n.length);try{let r=f/4;n.forEach((e=>l.HEAP32[r++]=e));const a=l._OrtCreateTensor((0,o.tensorDataTypeStringToEnum)(t),i,u,f,n.length);0===a&&(0,s.checkLastError)(`Can\'t create tensor for input[${e}].`),b.push(a)}finally{l.stackRestore(c)}}const e=l.stackSave(),i=l.stackAlloc(4*h),u=l.stackAlloc(4*h),f=l.stackAlloc(4*m),_=l.stackAlloc(4*m);try{let e=i/4,r=u/4,n=f/4,c=_/4;for(let n=0;n<h;n++)l.HEAPU32[e++]=b[n],l.HEAPU32[r++]=p[t[n]];for(let e=0;e<m;e++)l.HEAPU32[n++]=0,l.HEAPU32[c++]=g[a[e]];let v=l._OrtRun(d,u,i,h,_,m,f,y);const w=l.jsepRunPromise;w&&void 0!==w.then&&(v=await w);const O=[];0!==v&&(0,s.checkLastError)("failed to call OrtRun().");for(let e=0;e<m;e++){const t=l.HEAPU32[f/4+e],r=l.stackSave(),n=l.stackAlloc(16);let a,i=0;try{v=l._OrtGetTensorData(t,n,n+4,n+8,n+12),0!==v&&(0,s.checkLastError)(`Can\'t access output tensor data on index ${e}.`);let r=n/4;const u=l.HEAPU32[r++];i=l.HEAPU32[r++];const c=l.HEAPU32[r++],f=l.HEAPU32[r++],d=[];for(let e=0;e<f;e++)d.push(l.HEAPU32[c/4+e]);l._OrtFree(c);const p=0===d.length?1:d.reduce(((e,t)=>e*t));if(a=(0,o.tensorDataTypeEnumToString)(u),"string"===a){const e=[];let t=i/4;for(let r=0;r<p;r++){const n=l.HEAPU32[t++],a=r===p-1?void 0:l.HEAPU32[t]-n;e.push(l.UTF8ToString(n,a))}O.push([a,d,e])}else{const e=new((0,o.tensorTypeToTypedArrayConstructor)(a))(p);new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(l.HEAPU8.subarray(i,i+e.byteLength)),O.push([a,d,e])}}finally{l.stackRestore(r),"string"===a&&i&&l._free(i),l._OrtReleaseTensor(t)}}return O}finally{l.stackRestore(e)}}finally{b.forEach((e=>l._OrtReleaseTensor(e))),w.forEach((e=>l._free(e))),0!==y&&l._OrtReleaseRunOptions(y),v.forEach((e=>l._free(e)))}},t.endProfiling=e=>{const t=(0,i.getInstance)(),r=u.get(e);if(!r)throw new Error("invalid session id");const n=r[0],a=t._OrtEndProfiling(n);0===a&&(0,s.checkLastError)("Can\'t get an profile file name."),t._OrtFree(a)},t.extractTransferableBuffers=e=>{const t=[];for(const r of e){const e=r[2];!Array.isArray(e)&&e.buffer&&t.push(e.buffer)}return t}},263:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return a(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.dispose=t.getInstance=t.initializeWebAssembly=void 0;const i=o(r(449)),s=r(932),u=r(474);let c,l=!1,f=!1,d=!1;t.initializeWebAssembly=async e=>{if(l)return Promise.resolve();if(f)throw new Error("multiple calls to \'initializeWebAssembly()\' detected.");if(d)throw new Error("previous call to \'initializeWebAssembly()\' failed.");f=!0;const t=e.initTimeout,n=e.numThreads,a=e.simd,o=n>1&&(()=>{try{return"undefined"!=typeof SharedArrayBuffer&&("undefined"!=typeof MessageChannel&&(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])))}catch(e){return!1}})(),p=a&&(()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch(e){return!1}})(),g=e.wasmPaths,h="string"==typeof g?g:void 0,m=((e,t)=>t?e?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":e?"ort-wasm-simd.wasm":"ort-wasm.wasm")(p,o),y="object"==typeof g?g[m]:void 0;let v=!1;const b=[];if(t>0&&b.push(new Promise((e=>{setTimeout((()=>{v=!0,e()}),t)}))),b.push(new Promise(((e,t)=>{const n=o?u:s,a={locateFile:(e,t)=>o&&e.endsWith(".worker.js")&&"undefined"!=typeof Blob?URL.createObjectURL(new Blob([r(154)],{type:"text/javascript"})):e.endsWith(".wasm")?y||(null!=h?h:t)+m:t+e};if(o)if("undefined"==typeof Blob)a.mainScriptUrlOrBlob=i.join(__dirname,"ort-wasm-threaded.js");else{const e=`var ortWasmThreaded=(function(){var _scriptDir;return ${n.toString()}})();`;a.mainScriptUrlOrBlob=new Blob([e],{type:"text/javascript"})}n(a).then((t=>{f=!1,l=!0,c=t,e()}),(e=>{f=!1,d=!0,t(e)}))}))),await Promise.race(b),v)throw new Error(`WebAssembly backend initializing failed due to timeout: ${t}ms`)},t.getInstance=()=>{if(l&&c)return c;throw new Error("WebAssembly is not initialized yet.")},t.dispose=()=>{var e;!l||f||d||(f=!0,null===(e=c.PThread)||void 0===e||e.terminateAllThreads(),c=void 0,f=!1,l=!1,d=!0)}},497:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkLastError=t.iterateExtraOptions=t.allocWasmString=void 0;const n=r(263);t.allocWasmString=(e,t)=>{const r=(0,n.getInstance)(),a=r.lengthBytesUTF8(e)+1,o=r._malloc(a);return r.stringToUTF8(e,o,a),t.push(o),o},t.iterateExtraOptions=(e,r,n,a)=>{if("object"==typeof e&&null!==e){if(n.has(e))throw new Error("Circular reference in options");n.add(e)}Object.entries(e).forEach((([e,o])=>{const i=r?r+e:e;if("object"==typeof o)(0,t.iterateExtraOptions)(o,i+".",n,a);else if("string"==typeof o||"number"==typeof o)a(i,o.toString());else{if("boolean"!=typeof o)throw new Error("Can\'t handle extra config type: "+typeof o);a(i,o?"1":"0")}}))},t.checkLastError=e=>{const t=(0,n.getInstance)(),r=t.stackSave();try{const r=t.stackAlloc(8);t._OrtGetLastError(r,r+4);const n=t.HEAP32[r/4],a=t.HEAPU32[r/4+1],o=a?t.UTF8ToString(a):"";throw new Error(`${e} ERROR_CODE: ${n}, ERROR_MESSAGE: ${o}`)}finally{t.stackRestore(r)}}},474:(e,t,r)=>{var _scriptDir,n=(_scriptDir="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,"undefined"!=typeof __filename&&(_scriptDir=_scriptDir||__filename),function(e={}){function t(){return k.buffer!=x.buffer&&Y(),x}function n(){return k.buffer!=x.buffer&&Y(),I}function a(){return k.buffer!=x.buffer&&Y(),U}function o(){return k.buffer!=x.buffer&&Y(),L}function i(){return k.buffer!=x.buffer&&Y(),W}var s,u,c=e;c.ready=new Promise(((e,t)=>{s=e,u=t}));var l,f,d,p=Object.assign({},c),g="./this.program",h=(e,t)=>{throw t},m="object"==typeof window,y="function"==typeof importScripts,v="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,b=c.ENVIRONMENT_IS_PTHREAD||!1,w="";function _(e){return c.locateFile?c.locateFile(e,w):w+e}if(v){var O=r(384),S=r(908);let t;w=y?S.dirname(w)+"/":__dirname+"/",l=(e,t)=>(e=e.startsWith("file://")?new URL(e):S.normalize(e),O.readFileSync(e,t?void 0:"utf8")),d=e=>((e=l(e,!0)).buffer||(e=new Uint8Array(e)),e),f=(e,t,r,n=!0)=>{e=e.startsWith("file://")?new URL(e):S.normalize(e),O.readFile(e,n?void 0:"utf8",((e,a)=>{e?r(e):t(n?a.buffer:a)}))},!c.thisProgram&&1<process.argv.length&&(g=process.argv[1].replace(/\\\\/g,"/")),process.argv.slice(2),h=(e,t)=>{throw process.exitCode=e,t},c.inspect=()=>"[Emscripten Module object]";try{t=r(925)}catch(e){throw console.error(\'The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?\'),e}global.Worker=t.Worker}else(m||y)&&(y?w=self.location.href:"undefined"!=typeof document&&document.currentScript&&(w=document.currentScript.src),_scriptDir&&(w=_scriptDir),w=0!==w.indexOf("blob:")?w.substr(0,w.replace(/[?#].*/,"").lastIndexOf("/")+1):"",v||(l=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},y&&(d=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),f=(e,t,r)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==n.status&&n.response?t(n.response):r()},n.onerror=r,n.send(null)}));v&&"undefined"==typeof performance&&(global.performance=r(953).performance);var E=console.log.bind(console),A=console.error.bind(console);v&&(E=(...e)=>O.writeSync(1,e.join(" ")+"\\n"),A=(...e)=>O.writeSync(2,e.join(" ")+"\\n"));var T,M=c.print||E,R=c.printErr||A;Object.assign(c,p),p=null,c.thisProgram&&(g=c.thisProgram),c.quit&&(h=c.quit),c.wasmBinary&&(T=c.wasmBinary);var F=c.noExitRuntime||!0;"object"!=typeof WebAssembly&&te("no native wasm support detected");var k,C,P,D,x,I,U,L,W,H=!1;function Y(){var e=k.buffer;c.HEAP8=x=new Int8Array(e),c.HEAP16=new Int16Array(e),c.HEAP32=U=new Int32Array(e),c.HEAPU8=I=new Uint8Array(e),c.HEAPU16=new Uint16Array(e),c.HEAPU32=L=new Uint32Array(e),c.HEAPF32=new Float32Array(e),c.HEAPF64=W=new Float64Array(e)}var j=c.INITIAL_MEMORY||16777216;if(5242880<=j||te("INITIAL_MEMORY should be larger than STACK_SIZE, was "+j+"! (STACK_SIZE=5242880)"),b)k=c.wasmMemory;else if(c.wasmMemory)k=c.wasmMemory;else if(!((k=new WebAssembly.Memory({initial:j/65536,maximum:65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw R("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),v&&R("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");Y(),j=k.buffer.byteLength;var z,G=[],N=[],B=[],$=0;function q(){return F||0<$}var V,J,X=0,K=null,Z=null;function Q(){X++,c.monitorRunDependencies&&c.monitorRunDependencies(X)}function ee(){if(X--,c.monitorRunDependencies&&c.monitorRunDependencies(X),0==X&&(null!==K&&(clearInterval(K),K=null),Z)){var e=Z;Z=null,e()}}function te(e){throw c.onAbort&&c.onAbort(e),R(e="Aborted("+e+")"),H=!0,D=1,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),u(e),e}function re(e){return e.startsWith("data:application/octet-stream;base64,")}function ne(e){if(e==V&&T)return new Uint8Array(T);if(d)return d(e);throw"both async and sync fetching of the wasm failed"}function ae(e,t,r){return function(e){if(!T&&(m||y)){if("function"==typeof fetch&&!e.startsWith("file://"))return fetch(e,{credentials:"same-origin"}).then((t=>{if(!t.ok)throw"failed to load wasm binary file at \'"+e+"\'";return t.arrayBuffer()})).catch((()=>ne(e)));if(f)return new Promise(((t,r)=>{f(e,(e=>t(new Uint8Array(e))),r)}))}return Promise.resolve().then((()=>ne(e)))}(e).then((e=>WebAssembly.instantiate(e,t))).then((e=>e)).then(r,(e=>{R("failed to asynchronously prepare wasm: "+e),te(e)}))}function oe(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}function ie(e){e.terminate(),e.onmessage=()=>{}}function se(e){(e=ge.Fa[e])||te(),ge.fb(e)}function ue(e){var t=ge.Za();if(!t)return 6;ge.Ia.push(t),ge.Fa[e.Ha]=t,t.Ha=e.Ha;var r={cmd:"run",start_routine:e.gb,arg:e.Ya,pthread_ptr:e.Ha};return v&&t.unref(),t.postMessage(r,e.mb),0}re(V="ort-wasm-threaded.wasm")||(V=_(V));var ce="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,le=(e,t,r)=>{var n=(t>>>=0)+r;for(r=t;e[r]&&!(r>=n);)++r;if(16<r-t&&e.buffer&&ce)return ce.decode(e.buffer instanceof SharedArrayBuffer?e.slice(t,r):e.subarray(t,r));for(n="";t<r;){var a=e[t++];if(128&a){var o=63&e[t++];if(192==(224&a))n+=String.fromCharCode((31&a)<<6|o);else{var i=63&e[t++];65536>(a=224==(240&a)?(15&a)<<12|o<<6|i:(7&a)<<18|o<<12|i<<6|63&e[t++])?n+=String.fromCharCode(a):(a-=65536,n+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else n+=String.fromCharCode(a)}return n},fe=(e,t)=>(e>>>=0)?le(n(),e,t):"";function de(e){if(b)return qe(1,1,e);D=e,q()||(ge.hb(),c.onExit&&c.onExit(e),H=!0),h(e,new oe(e))}var pe=e=>{if(D=e,b)throw me(e),"unwind";de(e)},ge={La:[],Ia:[],Ta:[],Fa:{},Pa:function(){b?ge.ab():ge.$a()},$a:function(){G.unshift((()=>{Q(),ge.bb((()=>ee()))}))},ab:function(){ge.receiveObjectTransfer=ge.eb,ge.threadInitTLS=ge.Sa,ge.setExitStatus=ge.Ra,F=!1},Ra:function(e){D=e},rb:["$terminateWorker"],hb:function(){for(var e of ge.Ia)ie(e);for(e of ge.La)ie(e);ge.La=[],ge.Ia=[],ge.Fa=[]},fb:function(e){var t=e.Ha;delete ge.Fa[t],ge.La.push(e),ge.Ia.splice(ge.Ia.indexOf(e),1),e.Ha=0,yt(t)},eb:function(){},Sa:function(){ge.Ta.forEach((e=>e()))},cb:e=>new Promise((t=>{e.onmessage=r=>{var n=(r=r.data).cmd;if(r.targetThread&&r.targetThread!=dt()){var a=ge.Fa[r.qb];a?a.postMessage(r,r.transferList):R(\'Internal error! Worker sent a message "\'+n+\'" to target pthread \'+r.targetThread+", but that thread no longer exists!")}else"checkMailbox"===n?He():"spawnThread"===n?ue(r):"cleanupThread"===n?se(r.thread):"killThread"===n?(r=r.thread,n=ge.Fa[r],delete ge.Fa[r],ie(n),yt(r),ge.Ia.splice(ge.Ia.indexOf(n),1),n.Ha=0):"cancelThread"===n?ge.Fa[r.thread].postMessage({cmd:"cancel"}):"loaded"===n?(e.loaded=!0,t(e)):"alert"===n?alert("Thread "+r.threadId+": "+r.text):"setimmediate"===r.target?e.postMessage(r):"callHandler"===n?c[r.handler](...r.args):n&&R("worker sent an unknown command "+n)},e.onerror=e=>{throw R("worker sent an error! "+e.filename+":"+e.lineno+": "+e.message),e},v&&(e.on("message",(function(t){e.onmessage({data:t})})),e.on("error",(function(t){e.onerror(t)})));var r,n=[];for(r of["onExit","onAbort","print","printErr"])c.hasOwnProperty(r)&&n.push(r);e.postMessage({cmd:"load",handlers:n,urlOrBlob:c.mainScriptUrlOrBlob||_scriptDir,wasmMemory:k,wasmModule:P})})),bb:function(e){e()},Xa:function(){var e=_("ort-wasm-threaded.worker.js");e=new Worker(e),ge.La.push(e)},Za:function(){return 0==ge.La.length&&(ge.Xa(),ge.cb(ge.La[0])),ge.La.pop()}};c.PThread=ge;var he=e=>{for(;0<e.length;)e.shift()(c)};function me(e){if(b)return qe(2,0,e);pe(e)}c.establishStackSpace=function(){var e=dt(),t=a()[e+52>>2>>>0];e=a()[e+56>>2>>>0],_t(t,t-e),St(t)};var ye=[];function ve(e){this.Oa=e-24,this.Wa=function(e){o()[this.Oa+4>>2>>>0]=e},this.Va=function(e){o()[this.Oa+8>>2>>>0]=e},this.Pa=function(e,t){this.Ua(),this.Wa(e),this.Va(t)},this.Ua=function(){o()[this.Oa+16>>2>>>0]=0}}function be(e,t,r,n){return b?qe(3,1,e,t,r,n):we(e,t,r,n)}function we(e,t,r,n){if(e>>>=0,t>>>=0,r>>>=0,n>>>=0,"undefined"==typeof SharedArrayBuffer)return R("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var a=[];return b&&0===a.length?be(e,t,r,n):(e={gb:r,Ha:e,Ya:n,mb:a},b?(e.ob="spawnThread",postMessage(e,a),0):ue(e))}function _e(e,t,r){return b?qe(4,1,e,t,r):0}function Oe(e,t){if(b)return qe(5,1,e,t)}c.invokeEntryPoint=function(e,t){var r=ye[e];r||(e>=ye.length&&(ye.length=e+1),ye[e]=r=z.get(e)),e=r(t),q()?ge.Ra(e):vt(e)};var Se=e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);127>=n?t++:2047>=n?t+=2:55296<=n&&57343>=n?(t+=4,++r):t+=3}return t},Ee=(e,t,r,n)=>{if(!(0<n))return 0;var a=r>>>=0;n=r+n-1;for(var o=0;o<e.length;++o){var i=e.charCodeAt(o);if(55296<=i&&57343>=i&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++o)),127>=i){if(r>=n)break;t[r++>>>0]=i}else{if(2047>=i){if(r+1>=n)break;t[r++>>>0]=192|i>>6}else{if(65535>=i){if(r+2>=n)break;t[r++>>>0]=224|i>>12}else{if(r+3>=n)break;t[r++>>>0]=240|i>>18,t[r++>>>0]=128|i>>12&63}t[r++>>>0]=128|i>>6&63}t[r++>>>0]=128|63&i}}return t[r>>>0]=0,r-a},Ae=(e,t,r)=>Ee(e,n(),t,r);function Te(e,t){if(b)return qe(6,1,e,t)}function Me(e,t,r){if(b)return qe(7,1,e,t,r)}function Re(e,t,r){return b?qe(8,1,e,t,r):0}function Fe(e,t){if(b)return qe(9,1,e,t)}function ke(e,t,r){if(b)return qe(10,1,e,t,r)}function Ce(e,t,r,n){if(b)return qe(11,1,e,t,r,n)}function Pe(e,t,r,n){if(b)return qe(12,1,e,t,r,n)}function De(e,t,r,n){if(b)return qe(13,1,e,t,r,n)}function xe(e){if(b)return qe(14,1,e)}function Ie(e,t){if(b)return qe(15,1,e,t)}function Ue(e,t,r){if(b)return qe(16,1,e,t,r)}var Le=e=>{if(!H)try{if(e(),!q())try{b?vt(D):pe(D)}catch(e){e instanceof oe||"unwind"==e||h(1,e)}}catch(e){e instanceof oe||"unwind"==e||h(1,e)}};function We(e){e>>>=0,"function"==typeof Atomics.nb&&(Atomics.nb(a(),e>>2,e).value.then(He),e+=128,Atomics.store(a(),e>>2,1))}function He(){var e=dt();e&&(We(e),Le((()=>bt())))}c.__emscripten_thread_mailbox_await=We,c.checkMailbox=He;var Ye=e=>0==e%4&&(0!=e%100||0==e%400),je=[0,31,60,91,121,152,182,213,244,274,305,335],ze=[0,31,59,90,120,151,181,212,243,273,304,334];function Ge(e,t,r,n,a,o,i,s){return b?qe(17,1,e,t,r,n,a,o,i,s):-52}function Ne(e,t,r,n,a,o,i){if(b)return qe(18,1,e,t,r,n,a,o,i)}var Be=e=>{var t=Se(e)+1,r=pt(t);return r&&Ae(e,r,t),r},$e=e=>{var t=Ot();return e=e(),St(t),e};function qe(e,t){var r=arguments.length-2,n=arguments;return $e((()=>{for(var a=Et(8*r),o=a>>3,s=0;s<r;s++){var u=n[2+s];i()[o+s>>>0]=u}return mt(e,r,a,t)}))}var Ve,Je=[],Xe={},Ke=()=>{if(!Ve){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:g||"./this.program"};for(e in Xe)void 0===Xe[e]?delete t[e]:t[e]=Xe[e];var r=[];for(e in t)r.push(`${e}=${t[e]}`);Ve=r}return Ve};function Ze(e,r){if(b)return qe(19,1,e,r);e>>>=0,r>>>=0;var n=0;return Ke().forEach((function(a,i){var s=r+n;for(i=o()[e+4*i>>2>>>0]=s,s=0;s<a.length;++s)t()[i++>>0>>>0]=a.charCodeAt(s);t()[i>>0>>>0]=0,n+=a.length+1})),0}function Qe(e,t){if(b)return qe(20,1,e,t);e>>>=0,t>>>=0;var r=Ke();o()[e>>2>>>0]=r.length;var n=0;return r.forEach((function(e){n+=e.length+1})),o()[t>>2>>>0]=n,0}function et(e){return b?qe(21,1,e):52}function tt(e,t,r,n){return b?qe(22,1,e,t,r,n):52}function rt(e,t,r,n,a){return b?qe(23,1,e,t,r,n,a):70}var nt=[null,[],[]];function at(e,t,r,a){if(b)return qe(24,1,e,t,r,a);t>>>=0,r>>>=0,a>>>=0;for(var i=0,s=0;s<r;s++){var u=o()[t>>2>>>0],c=o()[t+4>>2>>>0];t+=8;for(var l=0;l<c;l++){var f=n()[u+l>>>0],d=nt[e];0===f||10===f?((1===e?M:R)(le(d,0)),d.length=0):d.push(f)}i+=c}return o()[a>>2>>>0]=i,0}var ot=e=>(ot=(()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return e=>(e.set(crypto.getRandomValues(new Uint8Array(e.byteLength))),e);if(v)try{var e=r(760);if(e.randomFillSync)return t=>e.randomFillSync(t);var t=e.randomBytes;return e=>(e.set(t(e.byteLength)),e)}catch(e){}te("initRandomDevice")})())(e),it=[31,29,31,30,31,30,31,31,30,31,30,31],st=[31,28,31,30,31,30,31,31,30,31,30,31],ut=(e,r)=>{t().set(e,r>>>0)};function ct(e,t,r,n){function o(e,t,r){for(e="number"==typeof e?e.toString():e||"";e.length<t;)e=r[0]+e;return e}function i(e,t){return o(e,t,"0")}function s(e,t){function r(e){return 0>e?-1:0<e?1:0}var n;return 0===(n=r(e.getFullYear()-t.getFullYear()))&&0===(n=r(e.getMonth()-t.getMonth()))&&(n=r(e.getDate()-t.getDate())),n}function u(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function c(e){var t=e.Ja;for(e=new Date(new Date(e.Ka+1900,0,1).getTime());0<t;){var r=e.getMonth(),n=(Ye(e.getFullYear())?it:st)[r];if(!(t>n-e.getDate())){e.setDate(e.getDate()+t);break}t-=n-e.getDate()+1,e.setDate(1),11>r?e.setMonth(r+1):(e.setMonth(0),e.setFullYear(e.getFullYear()+1))}return r=new Date(e.getFullYear()+1,0,4),t=u(new Date(e.getFullYear(),0,4)),r=u(r),0>=s(t,e)?0>=s(r,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}e>>>=0,t>>>=0,r>>>=0,n>>>=0;var l=a()[n+40>>2>>>0];for(var f in n={kb:a()[n>>2>>>0],jb:a()[n+4>>2>>>0],Ma:a()[n+8>>2>>>0],Qa:a()[n+12>>2>>>0],Na:a()[n+16>>2>>>0],Ka:a()[n+20>>2>>>0],Ga:a()[n+24>>2>>>0],Ja:a()[n+28>>2>>>0],sb:a()[n+32>>2>>>0],ib:a()[n+36>>2>>>0],lb:l?fe(l):""},r=fe(r),l={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})r=r.replace(new RegExp(f,"g"),l[f]);var d="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),p="January February March April May June July August September October November December".split(" ");for(f in l={"%a":e=>d[e.Ga].substring(0,3),"%A":e=>d[e.Ga],"%b":e=>p[e.Na].substring(0,3),"%B":e=>p[e.Na],"%C":e=>i((e.Ka+1900)/100|0,2),"%d":e=>i(e.Qa,2),"%e":e=>o(e.Qa,2," "),"%g":e=>c(e).toString().substring(2),"%G":e=>c(e),"%H":e=>i(e.Ma,2),"%I":e=>(0==(e=e.Ma)?e=12:12<e&&(e-=12),i(e,2)),"%j":e=>{for(var t=0,r=0;r<=e.Na-1;t+=(Ye(e.Ka+1900)?it:st)[r++]);return i(e.Qa+t,3)},"%m":e=>i(e.Na+1,2),"%M":e=>i(e.jb,2),"%n":()=>"\\n","%p":e=>0<=e.Ma&&12>e.Ma?"AM":"PM","%S":e=>i(e.kb,2),"%t":()=>"\\t","%u":e=>e.Ga||7,"%U":e=>i(Math.floor((e.Ja+7-e.Ga)/7),2),"%V":e=>{var t=Math.floor((e.Ja+7-(e.Ga+6)%7)/7);if(2>=(e.Ga+371-e.Ja-2)%7&&t++,t)53==t&&(4==(r=(e.Ga+371-e.Ja)%7)||3==r&&Ye(e.Ka)||(t=1));else{t=52;var r=(e.Ga+7-e.Ja-1)%7;(4==r||5==r&&Ye(e.Ka%400-1))&&t++}return i(t,2)},"%w":e=>e.Ga,"%W":e=>i(Math.floor((e.Ja+7-(e.Ga+6)%7)/7),2),"%y":e=>(e.Ka+1900).toString().substring(2),"%Y":e=>e.Ka+1900,"%z":e=>{var t=0<=(e=e.ib);return e=Math.abs(e)/60,(t?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":e=>e.lb,"%%":()=>"%"},r=r.replace(/%%/g,"\\0\\0"),l)r.includes(f)&&(r=r.replace(new RegExp(f,"g"),l[f](n)));return f=function(e){var t=Array(Se(e)+1);return Ee(e,t,0,t.length),t}(r=r.replace(/\\0\\0/g,"%")),f.length>t?0:(ut(f,e),f.length-1)}ge.Pa();var lt=[null,de,me,be,_e,Oe,Te,Me,Re,Fe,ke,Ce,Pe,De,xe,Ie,Ue,Ge,Ne,Ze,Qe,et,tt,rt,at],ft={b:function(e,t,r){throw new ve(e>>>=0).Pa(t>>>0,r>>>0),e},N:function(e){gt(e>>>0,!y,1,!m,131072,!1),ge.Sa()},k:function(e){e>>>=0,b?postMessage({cmd:"cleanupThread",thread:e}):se(e)},I:we,h:_e,T:Oe,E:Te,G:Me,U:Re,R:Fe,J:ke,Q:Ce,o:Pe,F:De,C:xe,S:Ie,D:Ue,q:()=>!0,A:function(e,t){(e>>>=0)==t>>>0?setTimeout((()=>He())):b?postMessage({targetThread:e,cmd:"checkMailbox"}):(e=ge.Fa[e])&&e.postMessage({cmd:"checkMailbox"})},L:function(){return-1},M:We,p:function(e){v&&ge.Fa[e>>>0].ref()},t:function(e,t,r){e=t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN,r>>>=0,e=new Date(1e3*e),a()[r>>2>>>0]=e.getUTCSeconds(),a()[r+4>>2>>>0]=e.getUTCMinutes(),a()[r+8>>2>>>0]=e.getUTCHours(),a()[r+12>>2>>>0]=e.getUTCDate(),a()[r+16>>2>>>0]=e.getUTCMonth(),a()[r+20>>2>>>0]=e.getUTCFullYear()-1900,a()[r+24>>2>>>0]=e.getUTCDay(),e=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,a()[r+28>>2>>>0]=e},u:function(e,t,r){e=t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN,r>>>=0,e=new Date(1e3*e),a()[r>>2>>>0]=e.getSeconds(),a()[r+4>>2>>>0]=e.getMinutes(),a()[r+8>>2>>>0]=e.getHours(),a()[r+12>>2>>>0]=e.getDate(),a()[r+16>>2>>>0]=e.getMonth(),a()[r+20>>2>>>0]=e.getFullYear()-1900,a()[r+24>>2>>>0]=e.getDay(),t=(Ye(e.getFullYear())?je:ze)[e.getMonth()]+e.getDate()-1|0,a()[r+28>>2>>>0]=t,a()[r+36>>2>>>0]=-60*e.getTimezoneOffset(),t=new Date(e.getFullYear(),6,1).getTimezoneOffset();var n=new Date(e.getFullYear(),0,1).getTimezoneOffset();e=0|(t!=n&&e.getTimezoneOffset()==Math.min(n,t)),a()[r+32>>2>>>0]=e},v:function(e){e>>>=0;var t=new Date(a()[e+20>>2>>>0]+1900,a()[e+16>>2>>>0],a()[e+12>>2>>>0],a()[e+8>>2>>>0],a()[e+4>>2>>>0],a()[e>>2>>>0],0),r=a()[e+32>>2>>>0],n=t.getTimezoneOffset(),o=new Date(t.getFullYear(),6,1).getTimezoneOffset(),i=new Date(t.getFullYear(),0,1).getTimezoneOffset(),s=Math.min(i,o);return 0>r?a()[e+32>>2>>>0]=Number(o!=i&&s==n):0<r!=(s==n)&&(o=Math.max(i,o),t.setTime(t.getTime()+6e4*((0<r?s:o)-n))),a()[e+24>>2>>>0]=t.getDay(),r=(Ye(t.getFullYear())?je:ze)[t.getMonth()]+t.getDate()-1|0,a()[e+28>>2>>>0]=r,a()[e>>2>>>0]=t.getSeconds(),a()[e+4>>2>>>0]=t.getMinutes(),a()[e+8>>2>>>0]=t.getHours(),a()[e+12>>2>>>0]=t.getDate(),a()[e+16>>2>>>0]=t.getMonth(),a()[e+20>>2>>>0]=t.getYear(),e=t.getTime()/1e3,wt((J=e,1<=+Math.abs(J)?0<J?+Math.floor(J/4294967296)>>>0:~~+Math.ceil((J-+(~~J>>>0))/4294967296)>>>0:0)),e>>>0},r:Ge,s:Ne,z:function(e,t,r){function n(e){return(e=e.toTimeString().match(/\\(([A-Za-z ]+)\\)$/))?e[1]:"GMT"}e>>>=0,t>>>=0,r>>>=0;var i=(new Date).getFullYear(),s=new Date(i,0,1),u=new Date(i,6,1);i=s.getTimezoneOffset();var c=u.getTimezoneOffset(),l=Math.max(i,c);o()[e>>2>>>0]=60*l,a()[t>>2>>>0]=Number(i!=c),e=n(s),t=n(u),e=Be(e),t=Be(t),c<i?(o()[r>>2>>>0]=e,o()[r+4>>2>>>0]=t):(o()[r>>2>>>0]=t,o()[r+4>>2>>>0]=e)},c:()=>{te("")},l:function(){},i:function(){return Date.now()},V:()=>{throw $+=1,"unwind"},B:function(){return 4294901760},e:()=>performance.timeOrigin+performance.now(),f:function(){return v?r(993).cpus().length:navigator.hardwareConcurrency},K:function(e,t,r,n){for(ge.pb=t>>>0,Je.length=r,t=n>>>0>>3,n=0;n<r;n++)Je[n]=i()[t+n>>>0];return lt[e].apply(null,Je)},y:function(e){e>>>=0;var t=n().length;if(e<=t||4294901760<e)return!1;for(var r=1;4>=r;r*=2){var a=t*(1+.2/r);a=Math.min(a,e+100663296);var o=Math;a=Math.max(e,a);e:{o=o.min.call(o,4294901760,a+(65536-a%65536)%65536)-k.buffer.byteLength+65535>>>16;try{k.grow(o),Y();var i=1;break e}catch(e){}i=void 0}if(i)return!0}return!1},O:Ze,P:Qe,j:pe,g:et,n:tt,w:rt,m:at,x:function(e,t){return e>>>=0,t>>>=0,ot(n().subarray(e>>>0,e+t>>>0)),0},a:k||c.wasmMemory,H:ct,d:function(e,t,r,n){return ct(e>>>0,t>>>0,r>>>0,n>>>0)}};!function(){function e(e,t){return e=e.exports,C=e=function(e){var t=e=>()=>e()>>>0,r=e=>t=>e(t)>>>0;return(e=Object.assign({},e)).__errno_location=t(e.__errno_location),e.pthread_self=t(e.pthread_self),e.malloc=r(e.malloc),e.stackSave=t(e.stackSave),e.stackAlloc=r(e.stackAlloc),e}(e),ge.Ta.push(C.sa),z=C.ta,N.unshift(C.W),P=t,ee(),e}var t={a:ft};if(Q(),c.instantiateWasm)try{return c.instantiateWasm(t,e)}catch(e){R("Module.instantiateWasm callback failed with error: "+e),u(e)}(function(e,t){var r=V;return T||"function"!=typeof WebAssembly.instantiateStreaming||re(r)||r.startsWith("file://")||v||"function"!=typeof fetch?ae(r,e,t):fetch(r,{credentials:"same-origin"}).then((n=>WebAssembly.instantiateStreaming(n,e).then(t,(function(n){return R("wasm streaming compile failed: "+n),R("falling back to ArrayBuffer instantiation"),ae(r,e,t)}))))})(t,(function(t){e(t.instance,t.module)})).catch(u)}(),c._OrtInit=(e,t)=>(c._OrtInit=C.X)(e,t),c._OrtGetLastError=(e,t)=>(c._OrtGetLastError=C.Y)(e,t),c._OrtCreateSessionOptions=(e,t,r,n,a,o,i,s,u,l)=>(c._OrtCreateSessionOptions=C.Z)(e,t,r,n,a,o,i,s,u,l),c._OrtAppendExecutionProvider=(e,t)=>(c._OrtAppendExecutionProvider=C._)(e,t),c._OrtAddSessionConfigEntry=(e,t,r)=>(c._OrtAddSessionConfigEntry=C.$)(e,t,r),c._OrtReleaseSessionOptions=e=>(c._OrtReleaseSessionOptions=C.aa)(e),c._OrtCreateSession=(e,t,r)=>(c._OrtCreateSession=C.ba)(e,t,r),c._OrtReleaseSession=e=>(c._OrtReleaseSession=C.ca)(e),c._OrtGetInputOutputCount=(e,t,r)=>(c._OrtGetInputOutputCount=C.da)(e,t,r),c._OrtGetInputName=(e,t)=>(c._OrtGetInputName=C.ea)(e,t),c._OrtGetOutputName=(e,t)=>(c._OrtGetOutputName=C.fa)(e,t),c._OrtFree=e=>(c._OrtFree=C.ga)(e),c._OrtCreateTensor=(e,t,r,n,a)=>(c._OrtCreateTensor=C.ha)(e,t,r,n,a),c._OrtGetTensorData=(e,t,r,n,a)=>(c._OrtGetTensorData=C.ia)(e,t,r,n,a),c._OrtReleaseTensor=e=>(c._OrtReleaseTensor=C.ja)(e),c._OrtCreateRunOptions=(e,t,r,n)=>(c._OrtCreateRunOptions=C.ka)(e,t,r,n),c._OrtAddRunConfigEntry=(e,t,r)=>(c._OrtAddRunConfigEntry=C.la)(e,t,r),c._OrtReleaseRunOptions=e=>(c._OrtReleaseRunOptions=C.ma)(e),c._OrtRun=(e,t,r,n,a,o,i,s)=>(c._OrtRun=C.na)(e,t,r,n,a,o,i,s),c._OrtEndProfiling=e=>(c._OrtEndProfiling=C.oa)(e);var dt=c._pthread_self=()=>(dt=c._pthread_self=C.pa)(),pt=c._malloc=e=>(pt=c._malloc=C.qa)(e);c._free=e=>(c._free=C.ra)(e),c.__emscripten_tls_init=()=>(c.__emscripten_tls_init=C.sa)();var gt=c.__emscripten_thread_init=(e,t,r,n,a,o)=>(gt=c.__emscripten_thread_init=C.ua)(e,t,r,n,a,o);c.__emscripten_thread_crashed=()=>(c.__emscripten_thread_crashed=C.va)();var ht,mt=(e,t,r,n)=>(mt=C.wa)(e,t,r,n),yt=e=>(yt=C.xa)(e),vt=c.__emscripten_thread_exit=e=>(vt=c.__emscripten_thread_exit=C.ya)(e),bt=c.__emscripten_check_mailbox=()=>(bt=c.__emscripten_check_mailbox=C.za)(),wt=e=>(wt=C.Aa)(e),_t=(e,t)=>(_t=C.Ba)(e,t),Ot=()=>(Ot=C.Ca)(),St=e=>(St=C.Da)(e),Et=e=>(Et=C.Ea)(e);function At(){function e(){if(!ht&&(ht=!0,c.calledRun=!0,!H)&&(b||he(N),s(c),c.onRuntimeInitialized&&c.onRuntimeInitialized(),!b)){if(c.postRun)for("function"==typeof c.postRun&&(c.postRun=[c.postRun]);c.postRun.length;){var e=c.postRun.shift();B.unshift(e)}he(B)}}if(!(0<X))if(b)s(c),b||he(N),startWorker(c);else{if(c.preRun)for("function"==typeof c.preRun&&(c.preRun=[c.preRun]);c.preRun.length;)G.unshift(c.preRun.shift());he(G),0<X||(c.setStatus?(c.setStatus("Running..."),setTimeout((function(){setTimeout((function(){c.setStatus("")}),1),e()}),1)):e())}}if(c.keepRuntimeAlive=q,c.wasmMemory=k,c.stackAlloc=Et,c.stackSave=Ot,c.stackRestore=St,c.UTF8ToString=fe,c.stringToUTF8=Ae,c.lengthBytesUTF8=Se,c.ExitStatus=oe,c.PThread=ge,Z=function e(){ht||At(),ht||(Z=e)},c.preInit)for("function"==typeof c.preInit&&(c.preInit=[c.preInit]);0<c.preInit.length;)c.preInit.pop()();return At(),e.ready});e.exports=n},932:(e,t,r)=>{var _scriptDir,n=(_scriptDir="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,"undefined"!=typeof __filename&&(_scriptDir=_scriptDir||__filename),function(e={}){var t,n,a=e;a.ready=new Promise(((e,r)=>{t=e,n=r}));var o,i,s,u=Object.assign({},a),c="./this.program",l=(e,t)=>{throw t},f="object"==typeof window,d="function"==typeof importScripts,p="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,g="";if(p){var h=r(384),m=r(908);g=d?m.dirname(g)+"/":__dirname+"/",o=(e,t)=>(e=e.startsWith("file://")?new URL(e):m.normalize(e),h.readFileSync(e,t?void 0:"utf8")),s=e=>((e=o(e,!0)).buffer||(e=new Uint8Array(e)),e),i=(e,t,r,n=!0)=>{e=e.startsWith("file://")?new URL(e):m.normalize(e),h.readFile(e,n?void 0:"utf8",((e,a)=>{e?r(e):t(n?a.buffer:a)}))},!a.thisProgram&&1<process.argv.length&&(c=process.argv[1].replace(/\\\\/g,"/")),process.argv.slice(2),l=(e,t)=>{throw process.exitCode=e,t},a.inspect=()=>"[Emscripten Module object]"}else(f||d)&&(d?g=self.location.href:"undefined"!=typeof document&&document.currentScript&&(g=document.currentScript.src),_scriptDir&&(g=_scriptDir),g=0!==g.indexOf("blob:")?g.substr(0,g.replace(/[?#].*/,"").lastIndexOf("/")+1):"",o=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},d&&(s=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),i=(e,t,r)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==n.status&&n.response?t(n.response):r()},n.onerror=r,n.send(null)});var y,v=a.print||console.log.bind(console),b=a.printErr||console.error.bind(console);Object.assign(a,u),u=null,a.thisProgram&&(c=a.thisProgram),a.quit&&(l=a.quit),a.wasmBinary&&(y=a.wasmBinary);var w=a.noExitRuntime||!0;"object"!=typeof WebAssembly&&W("no native wasm support detected");var _,O,S,E,A,T,M=!1;function R(){var e=_.buffer;a.HEAP8=S=new Int8Array(e),a.HEAP16=new Int16Array(e),a.HEAP32=A=new Int32Array(e),a.HEAPU8=E=new Uint8Array(e),a.HEAPU16=new Uint16Array(e),a.HEAPU32=T=new Uint32Array(e),a.HEAPF32=new Float32Array(e),a.HEAPF64=new Float64Array(e)}var F=[],k=[],C=[];function P(){var e=a.preRun.shift();F.unshift(e)}var D,x,I=0,U=null,L=null;function W(e){throw a.onAbort&&a.onAbort(e),b(e="Aborted("+e+")"),M=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),n(e),e}function H(e){return e.startsWith("data:application/octet-stream;base64,")}if(!H(D="ort-wasm.wasm")){var Y=D;D=a.locateFile?a.locateFile(Y,g):g+Y}function j(e){if(e==D&&y)return new Uint8Array(y);if(s)return s(e);throw"both async and sync fetching of the wasm failed"}function z(e,t,r){return function(e){if(!y&&(f||d)){if("function"==typeof fetch&&!e.startsWith("file://"))return fetch(e,{credentials:"same-origin"}).then((t=>{if(!t.ok)throw"failed to load wasm binary file at \'"+e+"\'";return t.arrayBuffer()})).catch((()=>j(e)));if(i)return new Promise(((t,r)=>{i(e,(e=>t(new Uint8Array(e))),r)}))}return Promise.resolve().then((()=>j(e)))}(e).then((e=>WebAssembly.instantiate(e,t))).then((e=>e)).then(r,(e=>{b("failed to asynchronously prepare wasm: "+e),W(e)}))}function G(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var N=e=>{for(;0<e.length;)e.shift()(a)};function B(e){this.qa=e-24,this.va=function(e){T[this.qa+4>>2>>>0]=e},this.ua=function(e){T[this.qa+8>>2>>>0]=e},this.sa=function(e,t){this.ta(),this.va(e),this.ua(t)},this.ta=function(){T[this.qa+16>>2>>>0]=0}}var $,q="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,V=(e,t,r)=>{var n=(t>>>=0)+r;for(r=t;e[r]&&!(r>=n);)++r;if(16<r-t&&e.buffer&&q)return q.decode(e.subarray(t,r));for(n="";t<r;){var a=e[t++];if(128&a){var o=63&e[t++];if(192==(224&a))n+=String.fromCharCode((31&a)<<6|o);else{var i=63&e[t++];65536>(a=224==(240&a)?(15&a)<<12|o<<6|i:(7&a)<<18|o<<12|i<<6|63&e[t++])?n+=String.fromCharCode(a):(a-=65536,n+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else n+=String.fromCharCode(a)}return n},J=(e,t)=>(e>>>=0)?V(E,e,t):"",X=e=>{for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);127>=n?t++:2047>=n?t+=2:55296<=n&&57343>=n?(t+=4,++r):t+=3}return t},K=(e,t,r,n)=>{if(!(0<n))return 0;var a=r>>>=0;n=r+n-1;for(var o=0;o<e.length;++o){var i=e.charCodeAt(o);if(55296<=i&&57343>=i&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++o)),127>=i){if(r>=n)break;t[r++>>>0]=i}else{if(2047>=i){if(r+1>=n)break;t[r++>>>0]=192|i>>6}else{if(65535>=i){if(r+2>=n)break;t[r++>>>0]=224|i>>12}else{if(r+3>=n)break;t[r++>>>0]=240|i>>18,t[r++>>>0]=128|i>>12&63}t[r++>>>0]=128|i>>6&63}t[r++>>>0]=128|63&i}}return t[r>>>0]=0,r-a},Z=e=>0==e%4&&(0!=e%100||0==e%400),Q=[0,31,60,91,121,152,182,213,244,274,305,335],ee=[0,31,59,90,120,151,181,212,243,273,304,334],te=e=>{var t=X(e)+1,r=le(t);return r&&K(e,E,r,t),r},re={},ne=()=>{if(!$){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:c||"./this.program"};for(e in re)void 0===re[e]?delete t[e]:t[e]=re[e];var r=[];for(e in t)r.push(`${e}=${t[e]}`);$=r}return $},ae=[null,[],[]],oe=e=>(oe=(()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return e=>crypto.getRandomValues(e);if(p)try{var e=r(760);if(e.randomFillSync)return t=>e.randomFillSync(t);var t=e.randomBytes;return e=>(e.set(t(e.byteLength)),e)}catch(e){}W("initRandomDevice")})())(e),ie=[31,29,31,30,31,30,31,31,30,31,30,31],se=[31,28,31,30,31,30,31,31,30,31,30,31];function ue(e,t,r,n){function a(e,t,r){for(e="number"==typeof e?e.toString():e||"";e.length<t;)e=r[0]+e;return e}function o(e,t){return a(e,t,"0")}function i(e,t){function r(e){return 0>e?-1:0<e?1:0}var n;return 0===(n=r(e.getFullYear()-t.getFullYear()))&&0===(n=r(e.getMonth()-t.getMonth()))&&(n=r(e.getDate()-t.getDate())),n}function s(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function u(e){var t=e.ma;for(e=new Date(new Date(e.na+1900,0,1).getTime());0<t;){var r=e.getMonth(),n=(Z(e.getFullYear())?ie:se)[r];if(!(t>n-e.getDate())){e.setDate(e.getDate()+t);break}t-=n-e.getDate()+1,e.setDate(1),11>r?e.setMonth(r+1):(e.setMonth(0),e.setFullYear(e.getFullYear()+1))}return r=new Date(e.getFullYear()+1,0,4),t=s(new Date(e.getFullYear(),0,4)),r=s(r),0>=i(t,e)?0>=i(r,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}e>>>=0,t>>>=0,r>>>=0;var c=A[40+(n>>>=0)>>2>>>0];for(var l in n={ya:A[n>>2>>>0],xa:A[n+4>>2>>>0],oa:A[n+8>>2>>>0],ra:A[n+12>>2>>>0],pa:A[n+16>>2>>>0],na:A[n+20>>2>>>0],ha:A[n+24>>2>>>0],ma:A[n+28>>2>>>0],Aa:A[n+32>>2>>>0],wa:A[n+36>>2>>>0],za:c?J(c):""},r=J(r),c={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})r=r.replace(new RegExp(l,"g"),c[l]);var f="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),d="January February March April May June July August September October November December".split(" ");for(l in c={"%a":e=>f[e.ha].substring(0,3),"%A":e=>f[e.ha],"%b":e=>d[e.pa].substring(0,3),"%B":e=>d[e.pa],"%C":e=>o((e.na+1900)/100|0,2),"%d":e=>o(e.ra,2),"%e":e=>a(e.ra,2," "),"%g":e=>u(e).toString().substring(2),"%G":e=>u(e),"%H":e=>o(e.oa,2),"%I":e=>(0==(e=e.oa)?e=12:12<e&&(e-=12),o(e,2)),"%j":e=>{for(var t=0,r=0;r<=e.pa-1;t+=(Z(e.na+1900)?ie:se)[r++]);return o(e.ra+t,3)},"%m":e=>o(e.pa+1,2),"%M":e=>o(e.xa,2),"%n":()=>"\\n","%p":e=>0<=e.oa&&12>e.oa?"AM":"PM","%S":e=>o(e.ya,2),"%t":()=>"\\t","%u":e=>e.ha||7,"%U":e=>o(Math.floor((e.ma+7-e.ha)/7),2),"%V":e=>{var t=Math.floor((e.ma+7-(e.ha+6)%7)/7);if(2>=(e.ha+371-e.ma-2)%7&&t++,t)53==t&&(4==(r=(e.ha+371-e.ma)%7)||3==r&&Z(e.na)||(t=1));else{t=52;var r=(e.ha+7-e.ma-1)%7;(4==r||5==r&&Z(e.na%400-1))&&t++}return o(t,2)},"%w":e=>e.ha,"%W":e=>o(Math.floor((e.ma+7-(e.ha+6)%7)/7),2),"%y":e=>(e.na+1900).toString().substring(2),"%Y":e=>e.na+1900,"%z":e=>{var t=0<=(e=e.wa);return e=Math.abs(e)/60,(t?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":e=>e.za,"%%":()=>"%"},r=r.replace(/%%/g,"\\0\\0"),c)r.includes(l)&&(r=r.replace(new RegExp(l,"g"),c[l](n)));return l=function(e){var t=Array(X(e)+1);return K(e,t,0,t.length),t}(r=r.replace(/\\0\\0/g,"%")),l.length>t?0:(S.set(l,e>>>0),l.length-1)}var ce={a:function(e,t,r){throw new B(e>>>=0).sa(t>>>0,r>>>0),e},e:function(){return 0},I:function(){},y:function(){},A:function(){},K:function(){return 0},G:function(){},B:function(){},F:function(){},g:function(){},z:function(){},w:function(){},H:function(){},x:function(){},k:()=>!0,n:function(e,t,r){e=t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN,r>>>=0,e=new Date(1e3*e),A[r>>2>>>0]=e.getUTCSeconds(),A[r+4>>2>>>0]=e.getUTCMinutes(),A[r+8>>2>>>0]=e.getUTCHours(),A[r+12>>2>>>0]=e.getUTCDate(),A[r+16>>2>>>0]=e.getUTCMonth(),A[r+20>>2>>>0]=e.getUTCFullYear()-1900,A[r+24>>2>>>0]=e.getUTCDay(),A[r+28>>2>>>0]=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},o:function(e,t,r){e=t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN,r>>>=0,e=new Date(1e3*e),A[r>>2>>>0]=e.getSeconds(),A[r+4>>2>>>0]=e.getMinutes(),A[r+8>>2>>>0]=e.getHours(),A[r+12>>2>>>0]=e.getDate(),A[r+16>>2>>>0]=e.getMonth(),A[r+20>>2>>>0]=e.getFullYear()-1900,A[r+24>>2>>>0]=e.getDay(),A[r+28>>2>>>0]=(Z(e.getFullYear())?Q:ee)[e.getMonth()]+e.getDate()-1|0,A[r+36>>2>>>0]=-60*e.getTimezoneOffset(),t=new Date(e.getFullYear(),6,1).getTimezoneOffset();var n=new Date(e.getFullYear(),0,1).getTimezoneOffset();A[r+32>>2>>>0]=0|(t!=n&&e.getTimezoneOffset()==Math.min(n,t))},p:function(e){e>>>=0;var t=new Date(A[e+20>>2>>>0]+1900,A[e+16>>2>>>0],A[e+12>>2>>>0],A[e+8>>2>>>0],A[e+4>>2>>>0],A[e>>2>>>0],0),r=A[e+32>>2>>>0],n=t.getTimezoneOffset(),a=new Date(t.getFullYear(),6,1).getTimezoneOffset(),o=new Date(t.getFullYear(),0,1).getTimezoneOffset(),i=Math.min(o,a);return 0>r?A[e+32>>2>>>0]=Number(a!=o&&i==n):0<r!=(i==n)&&(a=Math.max(o,a),t.setTime(t.getTime()+6e4*((0<r?i:a)-n))),A[e+24>>2>>>0]=t.getDay(),A[e+28>>2>>>0]=(Z(t.getFullYear())?Q:ee)[t.getMonth()]+t.getDate()-1|0,A[e>>2>>>0]=t.getSeconds(),A[e+4>>2>>>0]=t.getMinutes(),A[e+8>>2>>>0]=t.getHours(),A[e+12>>2>>>0]=t.getDate(),A[e+16>>2>>>0]=t.getMonth(),A[e+20>>2>>>0]=t.getYear(),e=t.getTime()/1e3,de((x=e,1<=+Math.abs(x)?0<x?+Math.floor(x/4294967296)>>>0:~~+Math.ceil((x-+(~~x>>>0))/4294967296)>>>0:0)),e>>>0},l:function(){return-52},m:function(){},u:function(e,t,r){function n(e){return(e=e.toTimeString().match(/\\(([A-Za-z ]+)\\)$/))?e[1]:"GMT"}r>>>=0;var a=(new Date).getFullYear(),o=new Date(a,0,1),i=new Date(a,6,1);a=o.getTimezoneOffset();var s=i.getTimezoneOffset();T[e>>>0>>2>>>0]=60*Math.max(a,s),A[t>>>0>>2>>>0]=Number(a!=s),e=n(o),t=n(i),e=te(e),t=te(t),s<a?(T[r>>2>>>0]=e,T[r+4>>2>>>0]=t):(T[r>>2>>>0]=t,T[r+4>>2>>>0]=e)},d:()=>{W("")},h:function(){return Date.now()},v:function(){return 4294901760},b:()=>performance.now(),J:function(e,t,r){return t>>>=0,E.copyWithin(e>>>0>>>0,t>>>0,t+(r>>>0)>>>0)},t:function(e){e>>>=0;var t=E.length;if(4294901760<e)return!1;for(var r=1;4>=r;r*=2){var n=t*(1+.2/r);n=Math.min(n,e+100663296);var a=Math;n=Math.max(e,n);e:{a=a.min.call(a,4294901760,n+(65536-n%65536)%65536)-_.buffer.byteLength+65535>>>16;try{_.grow(a),R();var o=1;break e}catch(e){}o=void 0}if(o)return!0}return!1},D:function(e,t){e>>>=0,t>>>=0;var r=0;return ne().forEach((function(n,a){var o=t+r;for(a=T[e+4*a>>2>>>0]=o,o=0;o<n.length;++o)S[a++>>0>>>0]=n.charCodeAt(o);S[a>>0>>>0]=0,r+=n.length+1})),0},E:function(e,t){e>>>=0,t>>>=0;var r=ne();T[e>>2>>>0]=r.length;var n=0;return r.forEach((function(e){n+=e.length+1})),T[t>>2>>>0]=n,0},s:e=>{w||(a.onExit&&a.onExit(e),M=!0),l(e,new G(e))},f:()=>52,j:function(){return 52},q:function(){return 70},i:function(e,t,r,n){t>>>=0,r>>>=0,n>>>=0;for(var a=0,o=0;o<r;o++){var i=T[t>>2>>>0],s=T[t+4>>2>>>0];t+=8;for(var u=0;u<s;u++){var c=E[i+u>>>0],l=ae[e];0===c||10===c?((1===e?v:b)(V(l,0)),l.length=0):l.push(c)}a+=s}return T[n>>2>>>0]=a,0},r:function(e,t){return e>>>=0,oe(E.subarray(e>>>0,e+(t>>>0)>>>0)),0},C:ue,c:function(e,t,r,n){return ue(e>>>0,t>>>0,r>>>0,n>>>0)}};!function(){function e(e){if(e=e.exports,O=e=function(e){var t=e=>()=>e()>>>0,r=e=>t=>e(t)>>>0;return(e=Object.assign({},e)).__errno_location=t(e.__errno_location),e.malloc=r(e.malloc),e.stackSave=t(e.stackSave),e.stackAlloc=r(e.stackAlloc),e}(e),_=O.L,R(),k.unshift(O.M),I--,a.monitorRunDependencies&&a.monitorRunDependencies(I),0==I&&(null!==U&&(clearInterval(U),U=null),L)){var t=L;L=null,t()}return e}var t={a:ce};if(I++,a.monitorRunDependencies&&a.monitorRunDependencies(I),a.instantiateWasm)try{return a.instantiateWasm(t,e)}catch(e){b("Module.instantiateWasm callback failed with error: "+e),n(e)}(function(e,t){var r=D;return y||"function"!=typeof WebAssembly.instantiateStreaming||H(r)||r.startsWith("file://")||p||"function"!=typeof fetch?z(r,e,t):fetch(r,{credentials:"same-origin"}).then((n=>WebAssembly.instantiateStreaming(n,e).then(t,(function(n){return b("wasm streaming compile failed: "+n),b("falling back to ArrayBuffer instantiation"),z(r,e,t)}))))})(t,(function(t){e(t.instance)})).catch(n)}(),a._OrtInit=(e,t)=>(a._OrtInit=O.N)(e,t),a._OrtGetLastError=(e,t)=>(a._OrtGetLastError=O.O)(e,t),a._OrtCreateSessionOptions=(e,t,r,n,o,i,s,u,c,l)=>(a._OrtCreateSessionOptions=O.P)(e,t,r,n,o,i,s,u,c,l),a._OrtAppendExecutionProvider=(e,t)=>(a._OrtAppendExecutionProvider=O.Q)(e,t),a._OrtAddSessionConfigEntry=(e,t,r)=>(a._OrtAddSessionConfigEntry=O.R)(e,t,r),a._OrtReleaseSessionOptions=e=>(a._OrtReleaseSessionOptions=O.S)(e),a._OrtCreateSession=(e,t,r)=>(a._OrtCreateSession=O.T)(e,t,r),a._OrtReleaseSession=e=>(a._OrtReleaseSession=O.U)(e),a._OrtGetInputOutputCount=(e,t,r)=>(a._OrtGetInputOutputCount=O.V)(e,t,r),a._OrtGetInputName=(e,t)=>(a._OrtGetInputName=O.W)(e,t),a._OrtGetOutputName=(e,t)=>(a._OrtGetOutputName=O.X)(e,t),a._OrtFree=e=>(a._OrtFree=O.Y)(e),a._OrtCreateTensor=(e,t,r,n,o)=>(a._OrtCreateTensor=O.Z)(e,t,r,n,o),a._OrtGetTensorData=(e,t,r,n,o)=>(a._OrtGetTensorData=O._)(e,t,r,n,o),a._OrtReleaseTensor=e=>(a._OrtReleaseTensor=O.$)(e),a._OrtCreateRunOptions=(e,t,r,n)=>(a._OrtCreateRunOptions=O.aa)(e,t,r,n),a._OrtAddRunConfigEntry=(e,t,r)=>(a._OrtAddRunConfigEntry=O.ba)(e,t,r),a._OrtReleaseRunOptions=e=>(a._OrtReleaseRunOptions=O.ca)(e),a._OrtRun=(e,t,r,n,o,i,s,u)=>(a._OrtRun=O.da)(e,t,r,n,o,i,s,u),a._OrtEndProfiling=e=>(a._OrtEndProfiling=O.ea)(e);var le=a._malloc=e=>(le=a._malloc=O.fa)(e);a._free=e=>(a._free=O.ga)(e);var fe,de=e=>(de=O.ia)(e),pe=()=>(pe=O.ja)(),ge=e=>(ge=O.ka)(e),he=e=>(he=O.la)(e);function me(){function e(){if(!fe&&(fe=!0,a.calledRun=!0,!M)){if(N(k),t(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),a.postRun)for("function"==typeof a.postRun&&(a.postRun=[a.postRun]);a.postRun.length;){var e=a.postRun.shift();C.unshift(e)}N(C)}}if(!(0<I)){if(a.preRun)for("function"==typeof a.preRun&&(a.preRun=[a.preRun]);a.preRun.length;)P();N(F),0<I||(a.setStatus?(a.setStatus("Running..."),setTimeout((function(){setTimeout((function(){a.setStatus("")}),1),e()}),1)):e())}}if(a.stackAlloc=he,a.stackSave=pe,a.stackRestore=ge,a.UTF8ToString=J,a.stringToUTF8=(e,t,r)=>K(e,E,t,r),a.lengthBytesUTF8=X,L=function e(){fe||me(),fe||(L=e)},a.preInit)for("function"==typeof a.preInit&&(a.preInit=[a.preInit]);0<a.preInit.length;)a.preInit.pop()();return me(),e.ready});e.exports=n},154:e=>{"use strict";e.exports=\'"use strict";var e={},a="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node;if(a){var r=require("worker_threads"),t=r.parentPort;t.on("message",(e=>onmessage({data:e})));var s=require("fs");Object.assign(global,{self:global,require:require,Module:e,location:{href:__filename},Worker:r.Worker,importScripts:e=>(0,eval)(s.readFileSync(e,"utf8")+"//# sourceURL="+e),postMessage:e=>t.postMessage(e),performance:global.performance||{now:Date.now}})}var o=!1,d=function(){var e=Array.prototype.slice.call(arguments).join(" ");a?s.writeSync(2,e+"\\\\n"):console.error(e)};self.alert=function(){var a=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:a,threadId:e._pthread_self()})},e.instantiateWasm=(a,r)=>{var t=e.wasmModule;return e.wasmModule=null,r(new WebAssembly.Instance(t,a))},self.onunhandledrejection=e=>{throw e.reason??e},self.onmessage=function a(r){try{if("load"===r.data.cmd){let s=[];self.onmessage=e=>s.push(e),self.startWorker=r=>{e=r,postMessage({cmd:"loaded"});for(let e of s)a(e);self.onmessage=a},e.wasmModule=r.data.wasmModule;for(const a of r.data.handlers)e[a]=(...e)=>{postMessage({cmd:"callHandler",handler:a,args:e})};if(e.wasmMemory=r.data.wasmMemory,e.buffer=e.wasmMemory.buffer,e.ENVIRONMENT_IS_PTHREAD=!0,"string"==typeof r.data.urlOrBlob)importScripts(r.data.urlOrBlob);else{var t=URL.createObjectURL(r.data.urlOrBlob);importScripts(t),URL.revokeObjectURL(t)}ortWasmThreaded(e)}else if("run"===r.data.cmd){e.__emscripten_thread_init(r.data.pthread_ptr,0,0,1),e.__emscripten_thread_mailbox_await(r.data.pthread_ptr),e.establishStackSpace(),e.PThread.receiveObjectTransfer(r.data),e.PThread.threadInitTLS(),o||(o=!0);try{e.invokeEntryPoint(r.data.start_routine,r.data.arg)}catch(e){if("unwind"!=e)throw e}}else"cancel"===r.data.cmd?e._pthread_self()&&e.__emscripten_thread_exit(-1):"setimmediate"===r.data.target||("checkMailbox"===r.data.cmd?o&&e.checkMailbox():r.data.cmd&&(d("worker.js received unknown command "+r.data.cmd),d(r.data)))}catch(a){throw e.__emscripten_thread_crashed&&e.__emscripten_thread_crashed(),a}};\\n\'},760:()=>{},384:()=>{},993:()=>{},908:()=>{},953:()=>{},925:()=>{},449:()=>{}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,r),o.exports}(()=>{"use strict";const e=r(259),t=r(263);self.onmessage=r=>{switch(r.data.type){case"init-wasm":try{(0,t.initializeWebAssembly)(r.data.in).then((()=>postMessage({type:"init-wasm"})),(e=>postMessage({type:"init-wasm",err:e})))}catch(e){postMessage({type:"init-wasm",err:e})}break;case"init-ort":try{(0,e.initRuntime)(r.data.in).then((()=>postMessage({type:"init-ort"})),(e=>postMessage({type:"init-ort",err:e}))),postMessage({type:"init-ort"})}catch(e){postMessage({type:"init-ort",err:e})}break;case"create_allocate":try{const{model:t}=r.data.in,n=(0,e.createSessionAllocate)(t);postMessage({type:"create_allocate",out:n})}catch(e){postMessage({type:"create_allocate",err:e})}break;case"create_finalize":try{const{modeldata:t,options:n}=r.data.in,a=(0,e.createSessionFinalize)(t,n);postMessage({type:"create_finalize",out:a})}catch(e){postMessage({type:"create_finalize",err:e})}break;case"create":try{const{model:t,options:n}=r.data.in,a=(0,e.createSession)(t,n);postMessage({type:"create",out:a})}catch(e){postMessage({type:"create",err:e})}break;case"release":try{const t=r.data.in;(0,e.releaseSession)(t),postMessage({type:"release"})}catch(e){postMessage({type:"release",err:e})}break;case"run":try{const{sessionId:t,inputIndices:n,inputs:a,outputIndices:o,options:i}=r.data.in;(0,e.run)(t,n,a,o,i).then((t=>{postMessage({type:"run",out:t},(0,e.extractTransferableBuffers)(t))}),(e=>{postMessage({type:"run",err:e})}))}catch(e){postMessage({type:"run",err:e})}break;case"end-profiling":try{const t=r.data.in;(0,e.endProfiling)(t),postMessage({type:"end-profiling"})}catch(e){postMessage({type:"end-profiling",err:e})}}}})()})();\n',"Worker",void 0,void 0)}},6614:a=>{a.exports=function(e,n,t,r){var o=self||window;try{try{var s;try{s=new o.Blob([e])}catch{(s=new(o.BlobBuilder||o.WebKitBlobBuilder||o.MozBlobBuilder||o.MSBlobBuilder)).append(e),s=s.getBlob()}var l=o.URL||o.webkitURL,c=l.createObjectURL(s),f=new o[n](c,t);return l.revokeObjectURL(c),f}catch{return new o[n]("data:application/javascript,".concat(encodeURIComponent(e)),t)}}catch{if(!r)throw Error("Inline worker is not supported");return new o[n](r,t)}}},2446:(a,e,n)=>{var t,r,o,s=n(2100),l=s.Reader,c=s.Writer,f=s.util,h=s.roots.default||(s.roots.default={});h.onnx=((o={}).Version=(t={},(r=Object.create(t))[t[0]="_START_VERSION"]=0,r[t[1]="IR_VERSION_2017_10_10"]=1,r[t[2]="IR_VERSION_2017_10_30"]=2,r[t[3]="IR_VERSION_2017_11_3"]=3,r[t[4]="IR_VERSION_2019_1_22"]=4,r[t[5]="IR_VERSION_2019_3_18"]=5,r[t[6]="IR_VERSION_2019_9_19"]=6,r[t[7]="IR_VERSION_2020_5_8"]=7,r[t[8]="IR_VERSION_2021_7_30"]=8,r[t[9]="IR_VERSION"]=9,r),o.AttributeProto=function(){function u(i){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],this.sparseTensors=[],this.typeProtos=[],i)for(var d=Object.keys(i),p=0;p<d.length;++p)i[d[p]]!=null&&(this[d[p]]=i[d[p]])}return u.prototype.name="",u.prototype.refAttrName="",u.prototype.docString="",u.prototype.type=0,u.prototype.f=0,u.prototype.i=f.Long?f.Long.fromBits(0,0,!1):0,u.prototype.s=f.newBuffer([]),u.prototype.t=null,u.prototype.g=null,u.prototype.sparseTensor=null,u.prototype.tp=null,u.prototype.floats=f.emptyArray,u.prototype.ints=f.emptyArray,u.prototype.strings=f.emptyArray,u.prototype.tensors=f.emptyArray,u.prototype.graphs=f.emptyArray,u.prototype.sparseTensors=f.emptyArray,u.prototype.typeProtos=f.emptyArray,u.create=function(i){return new u(i)},u.encode=function(i,d){if(d||(d=c.create()),i.name!=null&&Object.hasOwnProperty.call(i,"name")&&d.uint32(10).string(i.name),i.f!=null&&Object.hasOwnProperty.call(i,"f")&&d.uint32(21).float(i.f),i.i!=null&&Object.hasOwnProperty.call(i,"i")&&d.uint32(24).int64(i.i),i.s!=null&&Object.hasOwnProperty.call(i,"s")&&d.uint32(34).bytes(i.s),i.t!=null&&Object.hasOwnProperty.call(i,"t")&&h.onnx.TensorProto.encode(i.t,d.uint32(42).fork()).ldelim(),i.g!=null&&Object.hasOwnProperty.call(i,"g")&&h.onnx.GraphProto.encode(i.g,d.uint32(50).fork()).ldelim(),i.floats!=null&&i.floats.length){d.uint32(58).fork();for(var p=0;p<i.floats.length;++p)d.float(i.floats[p]);d.ldelim()}if(i.ints!=null&&i.ints.length){for(d.uint32(66).fork(),p=0;p<i.ints.length;++p)d.int64(i.ints[p]);d.ldelim()}if(i.strings!=null&&i.strings.length)for(p=0;p<i.strings.length;++p)d.uint32(74).bytes(i.strings[p]);if(i.tensors!=null&&i.tensors.length)for(p=0;p<i.tensors.length;++p)h.onnx.TensorProto.encode(i.tensors[p],d.uint32(82).fork()).ldelim();if(i.graphs!=null&&i.graphs.length)for(p=0;p<i.graphs.length;++p)h.onnx.GraphProto.encode(i.graphs[p],d.uint32(90).fork()).ldelim();if(i.docString!=null&&Object.hasOwnProperty.call(i,"docString")&&d.uint32(106).string(i.docString),i.tp!=null&&Object.hasOwnProperty.call(i,"tp")&&h.onnx.TypeProto.encode(i.tp,d.uint32(114).fork()).ldelim(),i.typeProtos!=null&&i.typeProtos.length)for(p=0;p<i.typeProtos.length;++p)h.onnx.TypeProto.encode(i.typeProtos[p],d.uint32(122).fork()).ldelim();if(i.type!=null&&Object.hasOwnProperty.call(i,"type")&&d.uint32(160).int32(i.type),i.refAttrName!=null&&Object.hasOwnProperty.call(i,"refAttrName")&&d.uint32(170).string(i.refAttrName),i.sparseTensor!=null&&Object.hasOwnProperty.call(i,"sparseTensor")&&h.onnx.SparseTensorProto.encode(i.sparseTensor,d.uint32(178).fork()).ldelim(),i.sparseTensors!=null&&i.sparseTensors.length)for(p=0;p<i.sparseTensors.length;++p)h.onnx.SparseTensorProto.encode(i.sparseTensors[p],d.uint32(186).fork()).ldelim();return d},u.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},u.decode=function(i,d){i instanceof l||(i=l.create(i));for(var p=d===void 0?i.len:i.pos+d,_=new h.onnx.AttributeProto;i.pos<p;){var m=i.uint32();switch(m>>>3){case 1:_.name=i.string();break;case 21:_.refAttrName=i.string();break;case 13:_.docString=i.string();break;case 20:_.type=i.int32();break;case 2:_.f=i.float();break;case 3:_.i=i.int64();break;case 4:_.s=i.bytes();break;case 5:_.t=h.onnx.TensorProto.decode(i,i.uint32());break;case 6:_.g=h.onnx.GraphProto.decode(i,i.uint32());break;case 22:_.sparseTensor=h.onnx.SparseTensorProto.decode(i,i.uint32());break;case 14:_.tp=h.onnx.TypeProto.decode(i,i.uint32());break;case 7:if(_.floats&&_.floats.length||(_.floats=[]),(7&m)==2)for(var g=i.uint32()+i.pos;i.pos<g;)_.floats.push(i.float());else _.floats.push(i.float());break;case 8:if(_.ints&&_.ints.length||(_.ints=[]),(7&m)==2)for(g=i.uint32()+i.pos;i.pos<g;)_.ints.push(i.int64());else _.ints.push(i.int64());break;case 9:_.strings&&_.strings.length||(_.strings=[]),_.strings.push(i.bytes());break;case 10:_.tensors&&_.tensors.length||(_.tensors=[]),_.tensors.push(h.onnx.TensorProto.decode(i,i.uint32()));break;case 11:_.graphs&&_.graphs.length||(_.graphs=[]),_.graphs.push(h.onnx.GraphProto.decode(i,i.uint32()));break;case 23:_.sparseTensors&&_.sparseTensors.length||(_.sparseTensors=[]),_.sparseTensors.push(h.onnx.SparseTensorProto.decode(i,i.uint32()));break;case 15:_.typeProtos&&_.typeProtos.length||(_.typeProtos=[]),_.typeProtos.push(h.onnx.TypeProto.decode(i,i.uint32()));break;default:i.skipType(7&m)}}return _},u.decodeDelimited=function(i){return i instanceof l||(i=new l(i)),this.decode(i,i.uint32())},u.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.name!=null&&i.hasOwnProperty("name")&&!f.isString(i.name))return"name: string expected";if(i.refAttrName!=null&&i.hasOwnProperty("refAttrName")&&!f.isString(i.refAttrName))return"refAttrName: string expected";if(i.docString!=null&&i.hasOwnProperty("docString")&&!f.isString(i.docString))return"docString: string expected";if(i.type!=null&&i.hasOwnProperty("type"))switch(i.type){default:return"type: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 11:case 13:case 6:case 7:case 8:case 9:case 10:case 12:case 14:}if(i.f!=null&&i.hasOwnProperty("f")&&typeof i.f!="number")return"f: number expected";if(i.i!=null&&i.hasOwnProperty("i")&&!(f.isInteger(i.i)||i.i&&f.isInteger(i.i.low)&&f.isInteger(i.i.high)))return"i: integer|Long expected";if(i.s!=null&&i.hasOwnProperty("s")&&!(i.s&&typeof i.s.length=="number"||f.isString(i.s)))return"s: buffer expected";if(i.t!=null&&i.hasOwnProperty("t")&&(p=h.onnx.TensorProto.verify(i.t)))return"t."+p;if(i.g!=null&&i.hasOwnProperty("g")&&(p=h.onnx.GraphProto.verify(i.g)))return"g."+p;if(i.sparseTensor!=null&&i.hasOwnProperty("sparseTensor")&&(p=h.onnx.SparseTensorProto.verify(i.sparseTensor)))return"sparseTensor."+p;if(i.tp!=null&&i.hasOwnProperty("tp")&&(p=h.onnx.TypeProto.verify(i.tp)))return"tp."+p;if(i.floats!=null&&i.hasOwnProperty("floats")){if(!Array.isArray(i.floats))return"floats: array expected";for(var d=0;d<i.floats.length;++d)if(typeof i.floats[d]!="number")return"floats: number[] expected"}if(i.ints!=null&&i.hasOwnProperty("ints")){if(!Array.isArray(i.ints))return"ints: array expected";for(d=0;d<i.ints.length;++d)if(!(f.isInteger(i.ints[d])||i.ints[d]&&f.isInteger(i.ints[d].low)&&f.isInteger(i.ints[d].high)))return"ints: integer|Long[] expected"}if(i.strings!=null&&i.hasOwnProperty("strings")){if(!Array.isArray(i.strings))return"strings: array expected";for(d=0;d<i.strings.length;++d)if(!(i.strings[d]&&typeof i.strings[d].length=="number"||f.isString(i.strings[d])))return"strings: buffer[] expected"}if(i.tensors!=null&&i.hasOwnProperty("tensors")){if(!Array.isArray(i.tensors))return"tensors: array expected";for(d=0;d<i.tensors.length;++d)if(p=h.onnx.TensorProto.verify(i.tensors[d]))return"tensors."+p}if(i.graphs!=null&&i.hasOwnProperty("graphs")){if(!Array.isArray(i.graphs))return"graphs: array expected";for(d=0;d<i.graphs.length;++d)if(p=h.onnx.GraphProto.verify(i.graphs[d]))return"graphs."+p}if(i.sparseTensors!=null&&i.hasOwnProperty("sparseTensors")){if(!Array.isArray(i.sparseTensors))return"sparseTensors: array expected";for(d=0;d<i.sparseTensors.length;++d)if(p=h.onnx.SparseTensorProto.verify(i.sparseTensors[d]))return"sparseTensors."+p}if(i.typeProtos!=null&&i.hasOwnProperty("typeProtos")){if(!Array.isArray(i.typeProtos))return"typeProtos: array expected";for(d=0;d<i.typeProtos.length;++d){var p;if(p=h.onnx.TypeProto.verify(i.typeProtos[d]))return"typeProtos."+p}}return null},u.fromObject=function(i){if(i instanceof h.onnx.AttributeProto)return i;var d=new h.onnx.AttributeProto;switch(i.name!=null&&(d.name=String(i.name)),i.refAttrName!=null&&(d.refAttrName=String(i.refAttrName)),i.docString!=null&&(d.docString=String(i.docString)),i.type){default:if(typeof i.type=="number"){d.type=i.type;break}break;case"UNDEFINED":case 0:d.type=0;break;case"FLOAT":case 1:d.type=1;break;case"INT":case 2:d.type=2;break;case"STRING":case 3:d.type=3;break;case"TENSOR":case 4:d.type=4;break;case"GRAPH":case 5:d.type=5;break;case"SPARSE_TENSOR":case 11:d.type=11;break;case"TYPE_PROTO":case 13:d.type=13;break;case"FLOATS":case 6:d.type=6;break;case"INTS":case 7:d.type=7;break;case"STRINGS":case 8:d.type=8;break;case"TENSORS":case 9:d.type=9;break;case"GRAPHS":case 10:d.type=10;break;case"SPARSE_TENSORS":case 12:d.type=12;break;case"TYPE_PROTOS":case 14:d.type=14}if(i.f!=null&&(d.f=Number(i.f)),i.i!=null&&(f.Long?(d.i=f.Long.fromValue(i.i)).unsigned=!1:typeof i.i=="string"?d.i=parseInt(i.i,10):typeof i.i=="number"?d.i=i.i:typeof i.i=="object"&&(d.i=new f.LongBits(i.i.low>>>0,i.i.high>>>0).toNumber())),i.s!=null&&(typeof i.s=="string"?f.base64.decode(i.s,d.s=f.newBuffer(f.base64.length(i.s)),0):i.s.length>=0&&(d.s=i.s)),i.t!=null){if(typeof i.t!="object")throw TypeError(".onnx.AttributeProto.t: object expected");d.t=h.onnx.TensorProto.fromObject(i.t)}if(i.g!=null){if(typeof i.g!="object")throw TypeError(".onnx.AttributeProto.g: object expected");d.g=h.onnx.GraphProto.fromObject(i.g)}if(i.sparseTensor!=null){if(typeof i.sparseTensor!="object")throw TypeError(".onnx.AttributeProto.sparseTensor: object expected");d.sparseTensor=h.onnx.SparseTensorProto.fromObject(i.sparseTensor)}if(i.tp!=null){if(typeof i.tp!="object")throw TypeError(".onnx.AttributeProto.tp: object expected");d.tp=h.onnx.TypeProto.fromObject(i.tp)}if(i.floats){if(!Array.isArray(i.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");d.floats=[];for(var p=0;p<i.floats.length;++p)d.floats[p]=Number(i.floats[p])}if(i.ints){if(!Array.isArray(i.ints))throw TypeError(".onnx.AttributeProto.ints: array expected");for(d.ints=[],p=0;p<i.ints.length;++p)f.Long?(d.ints[p]=f.Long.fromValue(i.ints[p])).unsigned=!1:typeof i.ints[p]=="string"?d.ints[p]=parseInt(i.ints[p],10):typeof i.ints[p]=="number"?d.ints[p]=i.ints[p]:typeof i.ints[p]=="object"&&(d.ints[p]=new f.LongBits(i.ints[p].low>>>0,i.ints[p].high>>>0).toNumber())}if(i.strings){if(!Array.isArray(i.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");for(d.strings=[],p=0;p<i.strings.length;++p)typeof i.strings[p]=="string"?f.base64.decode(i.strings[p],d.strings[p]=f.newBuffer(f.base64.length(i.strings[p])),0):i.strings[p].length>=0&&(d.strings[p]=i.strings[p])}if(i.tensors){if(!Array.isArray(i.tensors))throw TypeError(".onnx.AttributeProto.tensors: array expected");for(d.tensors=[],p=0;p<i.tensors.length;++p){if(typeof i.tensors[p]!="object")throw TypeError(".onnx.AttributeProto.tensors: object expected");d.tensors[p]=h.onnx.TensorProto.fromObject(i.tensors[p])}}if(i.graphs){if(!Array.isArray(i.graphs))throw TypeError(".onnx.AttributeProto.graphs: array expected");for(d.graphs=[],p=0;p<i.graphs.length;++p){if(typeof i.graphs[p]!="object")throw TypeError(".onnx.AttributeProto.graphs: object expected");d.graphs[p]=h.onnx.GraphProto.fromObject(i.graphs[p])}}if(i.sparseTensors){if(!Array.isArray(i.sparseTensors))throw TypeError(".onnx.AttributeProto.sparseTensors: array expected");for(d.sparseTensors=[],p=0;p<i.sparseTensors.length;++p){if(typeof i.sparseTensors[p]!="object")throw TypeError(".onnx.AttributeProto.sparseTensors: object expected");d.sparseTensors[p]=h.onnx.SparseTensorProto.fromObject(i.sparseTensors[p])}}if(i.typeProtos){if(!Array.isArray(i.typeProtos))throw TypeError(".onnx.AttributeProto.typeProtos: array expected");for(d.typeProtos=[],p=0;p<i.typeProtos.length;++p){if(typeof i.typeProtos[p]!="object")throw TypeError(".onnx.AttributeProto.typeProtos: object expected");d.typeProtos[p]=h.onnx.TypeProto.fromObject(i.typeProtos[p])}}return d},u.toObject=function(i,d){d||(d={});var p={};if((d.arrays||d.defaults)&&(p.floats=[],p.ints=[],p.strings=[],p.tensors=[],p.graphs=[],p.typeProtos=[],p.sparseTensors=[]),d.defaults){if(p.name="",p.f=0,f.Long){var _=new f.Long(0,0,!1);p.i=d.longs===String?_.toString():d.longs===Number?_.toNumber():_}else p.i=d.longs===String?"0":0;d.bytes===String?p.s="":(p.s=[],d.bytes!==Array&&(p.s=f.newBuffer(p.s))),p.t=null,p.g=null,p.docString="",p.tp=null,p.type=d.enums===String?"UNDEFINED":0,p.refAttrName="",p.sparseTensor=null}if(i.name!=null&&i.hasOwnProperty("name")&&(p.name=i.name),i.f!=null&&i.hasOwnProperty("f")&&(p.f=d.json&&!isFinite(i.f)?String(i.f):i.f),i.i!=null&&i.hasOwnProperty("i")&&(typeof i.i=="number"?p.i=d.longs===String?String(i.i):i.i:p.i=d.longs===String?f.Long.prototype.toString.call(i.i):d.longs===Number?new f.LongBits(i.i.low>>>0,i.i.high>>>0).toNumber():i.i),i.s!=null&&i.hasOwnProperty("s")&&(p.s=d.bytes===String?f.base64.encode(i.s,0,i.s.length):d.bytes===Array?Array.prototype.slice.call(i.s):i.s),i.t!=null&&i.hasOwnProperty("t")&&(p.t=h.onnx.TensorProto.toObject(i.t,d)),i.g!=null&&i.hasOwnProperty("g")&&(p.g=h.onnx.GraphProto.toObject(i.g,d)),i.floats&&i.floats.length){p.floats=[];for(var m=0;m<i.floats.length;++m)p.floats[m]=d.json&&!isFinite(i.floats[m])?String(i.floats[m]):i.floats[m]}if(i.ints&&i.ints.length)for(p.ints=[],m=0;m<i.ints.length;++m)typeof i.ints[m]=="number"?p.ints[m]=d.longs===String?String(i.ints[m]):i.ints[m]:p.ints[m]=d.longs===String?f.Long.prototype.toString.call(i.ints[m]):d.longs===Number?new f.LongBits(i.ints[m].low>>>0,i.ints[m].high>>>0).toNumber():i.ints[m];if(i.strings&&i.strings.length)for(p.strings=[],m=0;m<i.strings.length;++m)p.strings[m]=d.bytes===String?f.base64.encode(i.strings[m],0,i.strings[m].length):d.bytes===Array?Array.prototype.slice.call(i.strings[m]):i.strings[m];if(i.tensors&&i.tensors.length)for(p.tensors=[],m=0;m<i.tensors.length;++m)p.tensors[m]=h.onnx.TensorProto.toObject(i.tensors[m],d);if(i.graphs&&i.graphs.length)for(p.graphs=[],m=0;m<i.graphs.length;++m)p.graphs[m]=h.onnx.GraphProto.toObject(i.graphs[m],d);if(i.docString!=null&&i.hasOwnProperty("docString")&&(p.docString=i.docString),i.tp!=null&&i.hasOwnProperty("tp")&&(p.tp=h.onnx.TypeProto.toObject(i.tp,d)),i.typeProtos&&i.typeProtos.length)for(p.typeProtos=[],m=0;m<i.typeProtos.length;++m)p.typeProtos[m]=h.onnx.TypeProto.toObject(i.typeProtos[m],d);if(i.type!=null&&i.hasOwnProperty("type")&&(p.type=d.enums===String?h.onnx.AttributeProto.AttributeType[i.type]===void 0?i.type:h.onnx.AttributeProto.AttributeType[i.type]:i.type),i.refAttrName!=null&&i.hasOwnProperty("refAttrName")&&(p.refAttrName=i.refAttrName),i.sparseTensor!=null&&i.hasOwnProperty("sparseTensor")&&(p.sparseTensor=h.onnx.SparseTensorProto.toObject(i.sparseTensor,d)),i.sparseTensors&&i.sparseTensors.length)for(p.sparseTensors=[],m=0;m<i.sparseTensors.length;++m)p.sparseTensors[m]=h.onnx.SparseTensorProto.toObject(i.sparseTensors[m],d);return p},u.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},u.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.AttributeProto"},u.AttributeType=function(){var i={},d=Object.create(i);return d[i[0]="UNDEFINED"]=0,d[i[1]="FLOAT"]=1,d[i[2]="INT"]=2,d[i[3]="STRING"]=3,d[i[4]="TENSOR"]=4,d[i[5]="GRAPH"]=5,d[i[11]="SPARSE_TENSOR"]=11,d[i[13]="TYPE_PROTO"]=13,d[i[6]="FLOATS"]=6,d[i[7]="INTS"]=7,d[i[8]="STRINGS"]=8,d[i[9]="TENSORS"]=9,d[i[10]="GRAPHS"]=10,d[i[12]="SPARSE_TENSORS"]=12,d[i[14]="TYPE_PROTOS"]=14,d}(),u}(),o.ValueInfoProto=function(){function u(i){if(i)for(var d=Object.keys(i),p=0;p<d.length;++p)i[d[p]]!=null&&(this[d[p]]=i[d[p]])}return u.prototype.name="",u.prototype.type=null,u.prototype.docString="",u.create=function(i){return new u(i)},u.encode=function(i,d){return d||(d=c.create()),i.name!=null&&Object.hasOwnProperty.call(i,"name")&&d.uint32(10).string(i.name),i.type!=null&&Object.hasOwnProperty.call(i,"type")&&h.onnx.TypeProto.encode(i.type,d.uint32(18).fork()).ldelim(),i.docString!=null&&Object.hasOwnProperty.call(i,"docString")&&d.uint32(26).string(i.docString),d},u.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},u.decode=function(i,d){i instanceof l||(i=l.create(i));for(var p=d===void 0?i.len:i.pos+d,_=new h.onnx.ValueInfoProto;i.pos<p;){var m=i.uint32();switch(m>>>3){case 1:_.name=i.string();break;case 2:_.type=h.onnx.TypeProto.decode(i,i.uint32());break;case 3:_.docString=i.string();break;default:i.skipType(7&m)}}return _},u.decodeDelimited=function(i){return i instanceof l||(i=new l(i)),this.decode(i,i.uint32())},u.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.name!=null&&i.hasOwnProperty("name")&&!f.isString(i.name))return"name: string expected";if(i.type!=null&&i.hasOwnProperty("type")){var d=h.onnx.TypeProto.verify(i.type);if(d)return"type."+d}return i.docString!=null&&i.hasOwnProperty("docString")&&!f.isString(i.docString)?"docString: string expected":null},u.fromObject=function(i){if(i instanceof h.onnx.ValueInfoProto)return i;var d=new h.onnx.ValueInfoProto;if(i.name!=null&&(d.name=String(i.name)),i.type!=null){if(typeof i.type!="object")throw TypeError(".onnx.ValueInfoProto.type: object expected");d.type=h.onnx.TypeProto.fromObject(i.type)}return i.docString!=null&&(d.docString=String(i.docString)),d},u.toObject=function(i,d){d||(d={});var p={};return d.defaults&&(p.name="",p.type=null,p.docString=""),i.name!=null&&i.hasOwnProperty("name")&&(p.name=i.name),i.type!=null&&i.hasOwnProperty("type")&&(p.type=h.onnx.TypeProto.toObject(i.type,d)),i.docString!=null&&i.hasOwnProperty("docString")&&(p.docString=i.docString),p},u.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},u.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.ValueInfoProto"},u}(),o.NodeProto=function(){function u(i){if(this.input=[],this.output=[],this.attribute=[],i)for(var d=Object.keys(i),p=0;p<d.length;++p)i[d[p]]!=null&&(this[d[p]]=i[d[p]])}return u.prototype.input=f.emptyArray,u.prototype.output=f.emptyArray,u.prototype.name="",u.prototype.opType="",u.prototype.domain="",u.prototype.attribute=f.emptyArray,u.prototype.docString="",u.create=function(i){return new u(i)},u.encode=function(i,d){if(d||(d=c.create()),i.input!=null&&i.input.length)for(var p=0;p<i.input.length;++p)d.uint32(10).string(i.input[p]);if(i.output!=null&&i.output.length)for(p=0;p<i.output.length;++p)d.uint32(18).string(i.output[p]);if(i.name!=null&&Object.hasOwnProperty.call(i,"name")&&d.uint32(26).string(i.name),i.opType!=null&&Object.hasOwnProperty.call(i,"opType")&&d.uint32(34).string(i.opType),i.attribute!=null&&i.attribute.length)for(p=0;p<i.attribute.length;++p)h.onnx.AttributeProto.encode(i.attribute[p],d.uint32(42).fork()).ldelim();return i.docString!=null&&Object.hasOwnProperty.call(i,"docString")&&d.uint32(50).string(i.docString),i.domain!=null&&Object.hasOwnProperty.call(i,"domain")&&d.uint32(58).string(i.domain),d},u.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},u.decode=function(i,d){i instanceof l||(i=l.create(i));for(var p=d===void 0?i.len:i.pos+d,_=new h.onnx.NodeProto;i.pos<p;){var m=i.uint32();switch(m>>>3){case 1:_.input&&_.input.length||(_.input=[]),_.input.push(i.string());break;case 2:_.output&&_.output.length||(_.output=[]),_.output.push(i.string());break;case 3:_.name=i.string();break;case 4:_.opType=i.string();break;case 7:_.domain=i.string();break;case 5:_.attribute&&_.attribute.length||(_.attribute=[]),_.attribute.push(h.onnx.AttributeProto.decode(i,i.uint32()));break;case 6:_.docString=i.string();break;default:i.skipType(7&m)}}return _},u.decodeDelimited=function(i){return i instanceof l||(i=new l(i)),this.decode(i,i.uint32())},u.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.input!=null&&i.hasOwnProperty("input")){if(!Array.isArray(i.input))return"input: array expected";for(var d=0;d<i.input.length;++d)if(!f.isString(i.input[d]))return"input: string[] expected"}if(i.output!=null&&i.hasOwnProperty("output")){if(!Array.isArray(i.output))return"output: array expected";for(d=0;d<i.output.length;++d)if(!f.isString(i.output[d]))return"output: string[] expected"}if(i.name!=null&&i.hasOwnProperty("name")&&!f.isString(i.name))return"name: string expected";if(i.opType!=null&&i.hasOwnProperty("opType")&&!f.isString(i.opType))return"opType: string expected";if(i.domain!=null&&i.hasOwnProperty("domain")&&!f.isString(i.domain))return"domain: string expected";if(i.attribute!=null&&i.hasOwnProperty("attribute")){if(!Array.isArray(i.attribute))return"attribute: array expected";for(d=0;d<i.attribute.length;++d){var p=h.onnx.AttributeProto.verify(i.attribute[d]);if(p)return"attribute."+p}}return i.docString!=null&&i.hasOwnProperty("docString")&&!f.isString(i.docString)?"docString: string expected":null},u.fromObject=function(i){if(i instanceof h.onnx.NodeProto)return i;var d=new h.onnx.NodeProto;if(i.input){if(!Array.isArray(i.input))throw TypeError(".onnx.NodeProto.input: array expected");d.input=[];for(var p=0;p<i.input.length;++p)d.input[p]=String(i.input[p])}if(i.output){if(!Array.isArray(i.output))throw TypeError(".onnx.NodeProto.output: array expected");for(d.output=[],p=0;p<i.output.length;++p)d.output[p]=String(i.output[p])}if(i.name!=null&&(d.name=String(i.name)),i.opType!=null&&(d.opType=String(i.opType)),i.domain!=null&&(d.domain=String(i.domain)),i.attribute){if(!Array.isArray(i.attribute))throw TypeError(".onnx.NodeProto.attribute: array expected");for(d.attribute=[],p=0;p<i.attribute.length;++p){if(typeof i.attribute[p]!="object")throw TypeError(".onnx.NodeProto.attribute: object expected");d.attribute[p]=h.onnx.AttributeProto.fromObject(i.attribute[p])}}return i.docString!=null&&(d.docString=String(i.docString)),d},u.toObject=function(i,d){d||(d={});var p={};if((d.arrays||d.defaults)&&(p.input=[],p.output=[],p.attribute=[]),d.defaults&&(p.name="",p.opType="",p.docString="",p.domain=""),i.input&&i.input.length){p.input=[];for(var _=0;_<i.input.length;++_)p.input[_]=i.input[_]}if(i.output&&i.output.length)for(p.output=[],_=0;_<i.output.length;++_)p.output[_]=i.output[_];if(i.name!=null&&i.hasOwnProperty("name")&&(p.name=i.name),i.opType!=null&&i.hasOwnProperty("opType")&&(p.opType=i.opType),i.attribute&&i.attribute.length)for(p.attribute=[],_=0;_<i.attribute.length;++_)p.attribute[_]=h.onnx.AttributeProto.toObject(i.attribute[_],d);return i.docString!=null&&i.hasOwnProperty("docString")&&(p.docString=i.docString),i.domain!=null&&i.hasOwnProperty("domain")&&(p.domain=i.domain),p},u.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},u.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.NodeProto"},u}(),o.TrainingInfoProto=function(){function u(i){if(this.initializationBinding=[],this.updateBinding=[],i)for(var d=Object.keys(i),p=0;p<d.length;++p)i[d[p]]!=null&&(this[d[p]]=i[d[p]])}return u.prototype.initialization=null,u.prototype.algorithm=null,u.prototype.initializationBinding=f.emptyArray,u.prototype.updateBinding=f.emptyArray,u.create=function(i){return new u(i)},u.encode=function(i,d){if(d||(d=c.create()),i.initialization!=null&&Object.hasOwnProperty.call(i,"initialization")&&h.onnx.GraphProto.encode(i.initialization,d.uint32(10).fork()).ldelim(),i.algorithm!=null&&Object.hasOwnProperty.call(i,"algorithm")&&h.onnx.GraphProto.encode(i.algorithm,d.uint32(18).fork()).ldelim(),i.initializationBinding!=null&&i.initializationBinding.length)for(var p=0;p<i.initializationBinding.length;++p)h.onnx.StringStringEntryProto.encode(i.initializationBinding[p],d.uint32(26).fork()).ldelim();if(i.updateBinding!=null&&i.updateBinding.length)for(p=0;p<i.updateBinding.length;++p)h.onnx.StringStringEntryProto.encode(i.updateBinding[p],d.uint32(34).fork()).ldelim();return d},u.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},u.decode=function(i,d){i instanceof l||(i=l.create(i));for(var p=d===void 0?i.len:i.pos+d,_=new h.onnx.TrainingInfoProto;i.pos<p;){var m=i.uint32();switch(m>>>3){case 1:_.initialization=h.onnx.GraphProto.decode(i,i.uint32());break;case 2:_.algorithm=h.onnx.GraphProto.decode(i,i.uint32());break;case 3:_.initializationBinding&&_.initializationBinding.length||(_.initializationBinding=[]),_.initializationBinding.push(h.onnx.StringStringEntryProto.decode(i,i.uint32()));break;case 4:_.updateBinding&&_.updateBinding.length||(_.updateBinding=[]),_.updateBinding.push(h.onnx.StringStringEntryProto.decode(i,i.uint32()));break;default:i.skipType(7&m)}}return _},u.decodeDelimited=function(i){return i instanceof l||(i=new l(i)),this.decode(i,i.uint32())},u.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.initialization!=null&&i.hasOwnProperty("initialization")&&(p=h.onnx.GraphProto.verify(i.initialization)))return"initialization."+p;if(i.algorithm!=null&&i.hasOwnProperty("algorithm")&&(p=h.onnx.GraphProto.verify(i.algorithm)))return"algorithm."+p;if(i.initializationBinding!=null&&i.hasOwnProperty("initializationBinding")){if(!Array.isArray(i.initializationBinding))return"initializationBinding: array expected";for(var d=0;d<i.initializationBinding.length;++d)if(p=h.onnx.StringStringEntryProto.verify(i.initializationBinding[d]))return"initializationBinding."+p}if(i.updateBinding!=null&&i.hasOwnProperty("updateBinding")){if(!Array.isArray(i.updateBinding))return"updateBinding: array expected";for(d=0;d<i.updateBinding.length;++d){var p;if(p=h.onnx.StringStringEntryProto.verify(i.updateBinding[d]))return"updateBinding."+p}}return null},u.fromObject=function(i){if(i instanceof h.onnx.TrainingInfoProto)return i;var d=new h.onnx.TrainingInfoProto;if(i.initialization!=null){if(typeof i.initialization!="object")throw TypeError(".onnx.TrainingInfoProto.initialization: object expected");d.initialization=h.onnx.GraphProto.fromObject(i.initialization)}if(i.algorithm!=null){if(typeof i.algorithm!="object")throw TypeError(".onnx.TrainingInfoProto.algorithm: object expected");d.algorithm=h.onnx.GraphProto.fromObject(i.algorithm)}if(i.initializationBinding){if(!Array.isArray(i.initializationBinding))throw TypeError(".onnx.TrainingInfoProto.initializationBinding: array expected");d.initializationBinding=[];for(var p=0;p<i.initializationBinding.length;++p){if(typeof i.initializationBinding[p]!="object")throw TypeError(".onnx.TrainingInfoProto.initializationBinding: object expected");d.initializationBinding[p]=h.onnx.StringStringEntryProto.fromObject(i.initializationBinding[p])}}if(i.updateBinding){if(!Array.isArray(i.updateBinding))throw TypeError(".onnx.TrainingInfoProto.updateBinding: array expected");for(d.updateBinding=[],p=0;p<i.updateBinding.length;++p){if(typeof i.updateBinding[p]!="object")throw TypeError(".onnx.TrainingInfoProto.updateBinding: object expected");d.updateBinding[p]=h.onnx.StringStringEntryProto.fromObject(i.updateBinding[p])}}return d},u.toObject=function(i,d){d||(d={});var p={};if((d.arrays||d.defaults)&&(p.initializationBinding=[],p.updateBinding=[]),d.defaults&&(p.initialization=null,p.algorithm=null),i.initialization!=null&&i.hasOwnProperty("initialization")&&(p.initialization=h.onnx.GraphProto.toObject(i.initialization,d)),i.algorithm!=null&&i.hasOwnProperty("algorithm")&&(p.algorithm=h.onnx.GraphProto.toObject(i.algorithm,d)),i.initializationBinding&&i.initializationBinding.length){p.initializationBinding=[];for(var _=0;_<i.initializationBinding.length;++_)p.initializationBinding[_]=h.onnx.StringStringEntryProto.toObject(i.initializationBinding[_],d)}if(i.updateBinding&&i.updateBinding.length)for(p.updateBinding=[],_=0;_<i.updateBinding.length;++_)p.updateBinding[_]=h.onnx.StringStringEntryProto.toObject(i.updateBinding[_],d);return p},u.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},u.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TrainingInfoProto"},u}(),o.ModelProto=function(){function u(i){if(this.opsetImport=[],this.metadataProps=[],this.trainingInfo=[],this.functions=[],i)for(var d=Object.keys(i),p=0;p<d.length;++p)i[d[p]]!=null&&(this[d[p]]=i[d[p]])}return u.prototype.irVersion=f.Long?f.Long.fromBits(0,0,!1):0,u.prototype.opsetImport=f.emptyArray,u.prototype.producerName="",u.prototype.producerVersion="",u.prototype.domain="",u.prototype.modelVersion=f.Long?f.Long.fromBits(0,0,!1):0,u.prototype.docString="",u.prototype.graph=null,u.prototype.metadataProps=f.emptyArray,u.prototype.trainingInfo=f.emptyArray,u.prototype.functions=f.emptyArray,u.create=function(i){return new u(i)},u.encode=function(i,d){if(d||(d=c.create()),i.irVersion!=null&&Object.hasOwnProperty.call(i,"irVersion")&&d.uint32(8).int64(i.irVersion),i.producerName!=null&&Object.hasOwnProperty.call(i,"producerName")&&d.uint32(18).string(i.producerName),i.producerVersion!=null&&Object.hasOwnProperty.call(i,"producerVersion")&&d.uint32(26).string(i.producerVersion),i.domain!=null&&Object.hasOwnProperty.call(i,"domain")&&d.uint32(34).string(i.domain),i.modelVersion!=null&&Object.hasOwnProperty.call(i,"modelVersion")&&d.uint32(40).int64(i.modelVersion),i.docString!=null&&Object.hasOwnProperty.call(i,"docString")&&d.uint32(50).string(i.docString),i.graph!=null&&Object.hasOwnProperty.call(i,"graph")&&h.onnx.GraphProto.encode(i.graph,d.uint32(58).fork()).ldelim(),i.opsetImport!=null&&i.opsetImport.length)for(var p=0;p<i.opsetImport.length;++p)h.onnx.OperatorSetIdProto.encode(i.opsetImport[p],d.uint32(66).fork()).ldelim();if(i.metadataProps!=null&&i.metadataProps.length)for(p=0;p<i.metadataProps.length;++p)h.onnx.StringStringEntryProto.encode(i.metadataProps[p],d.uint32(114).fork()).ldelim();if(i.trainingInfo!=null&&i.trainingInfo.length)for(p=0;p<i.trainingInfo.length;++p)h.onnx.TrainingInfoProto.encode(i.trainingInfo[p],d.uint32(162).fork()).ldelim();if(i.functions!=null&&i.functions.length)for(p=0;p<i.functions.length;++p)h.onnx.FunctionProto.encode(i.functions[p],d.uint32(202).fork()).ldelim();return d},u.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},u.decode=function(i,d){i instanceof l||(i=l.create(i));for(var p=d===void 0?i.len:i.pos+d,_=new h.onnx.ModelProto;i.pos<p;){var m=i.uint32();switch(m>>>3){case 1:_.irVersion=i.int64();break;case 8:_.opsetImport&&_.opsetImport.length||(_.opsetImport=[]),_.opsetImport.push(h.onnx.OperatorSetIdProto.decode(i,i.uint32()));break;case 2:_.producerName=i.string();break;case 3:_.producerVersion=i.string();break;case 4:_.domain=i.string();break;case 5:_.modelVersion=i.int64();break;case 6:_.docString=i.string();break;case 7:_.graph=h.onnx.GraphProto.decode(i,i.uint32());break;case 14:_.metadataProps&&_.metadataProps.length||(_.metadataProps=[]),_.metadataProps.push(h.onnx.StringStringEntryProto.decode(i,i.uint32()));break;case 20:_.trainingInfo&&_.trainingInfo.length||(_.trainingInfo=[]),_.trainingInfo.push(h.onnx.TrainingInfoProto.decode(i,i.uint32()));break;case 25:_.functions&&_.functions.length||(_.functions=[]),_.functions.push(h.onnx.FunctionProto.decode(i,i.uint32()));break;default:i.skipType(7&m)}}return _},u.decodeDelimited=function(i){return i instanceof l||(i=new l(i)),this.decode(i,i.uint32())},u.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.irVersion!=null&&i.hasOwnProperty("irVersion")&&!(f.isInteger(i.irVersion)||i.irVersion&&f.isInteger(i.irVersion.low)&&f.isInteger(i.irVersion.high)))return"irVersion: integer|Long expected";if(i.opsetImport!=null&&i.hasOwnProperty("opsetImport")){if(!Array.isArray(i.opsetImport))return"opsetImport: array expected";for(var d=0;d<i.opsetImport.length;++d)if(p=h.onnx.OperatorSetIdProto.verify(i.opsetImport[d]))return"opsetImport."+p}if(i.producerName!=null&&i.hasOwnProperty("producerName")&&!f.isString(i.producerName))return"producerName: string expected";if(i.producerVersion!=null&&i.hasOwnProperty("producerVersion")&&!f.isString(i.producerVersion))return"producerVersion: string expected";if(i.domain!=null&&i.hasOwnProperty("domain")&&!f.isString(i.domain))return"domain: string expected";if(i.modelVersion!=null&&i.hasOwnProperty("modelVersion")&&!(f.isInteger(i.modelVersion)||i.modelVersion&&f.isInteger(i.modelVersion.low)&&f.isInteger(i.modelVersion.high)))return"modelVersion: integer|Long expected";if(i.docString!=null&&i.hasOwnProperty("docString")&&!f.isString(i.docString))return"docString: string expected";if(i.graph!=null&&i.hasOwnProperty("graph")&&(p=h.onnx.GraphProto.verify(i.graph)))return"graph."+p;if(i.metadataProps!=null&&i.hasOwnProperty("metadataProps")){if(!Array.isArray(i.metadataProps))return"metadataProps: array expected";for(d=0;d<i.metadataProps.length;++d)if(p=h.onnx.StringStringEntryProto.verify(i.metadataProps[d]))return"metadataProps."+p}if(i.trainingInfo!=null&&i.hasOwnProperty("trainingInfo")){if(!Array.isArray(i.trainingInfo))return"trainingInfo: array expected";for(d=0;d<i.trainingInfo.length;++d)if(p=h.onnx.TrainingInfoProto.verify(i.trainingInfo[d]))return"trainingInfo."+p}if(i.functions!=null&&i.hasOwnProperty("functions")){if(!Array.isArray(i.functions))return"functions: array expected";for(d=0;d<i.functions.length;++d){var p;if(p=h.onnx.FunctionProto.verify(i.functions[d]))return"functions."+p}}return null},u.fromObject=function(i){if(i instanceof h.onnx.ModelProto)return i;var d=new h.onnx.ModelProto;if(i.irVersion!=null&&(f.Long?(d.irVersion=f.Long.fromValue(i.irVersion)).unsigned=!1:typeof i.irVersion=="string"?d.irVersion=parseInt(i.irVersion,10):typeof i.irVersion=="number"?d.irVersion=i.irVersion:typeof i.irVersion=="object"&&(d.irVersion=new f.LongBits(i.irVersion.low>>>0,i.irVersion.high>>>0).toNumber())),i.opsetImport){if(!Array.isArray(i.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");d.opsetImport=[];for(var p=0;p<i.opsetImport.length;++p){if(typeof i.opsetImport[p]!="object")throw TypeError(".onnx.ModelProto.opsetImport: object expected");d.opsetImport[p]=h.onnx.OperatorSetIdProto.fromObject(i.opsetImport[p])}}if(i.producerName!=null&&(d.producerName=String(i.producerName)),i.producerVersion!=null&&(d.producerVersion=String(i.producerVersion)),i.domain!=null&&(d.domain=String(i.domain)),i.modelVersion!=null&&(f.Long?(d.modelVersion=f.Long.fromValue(i.modelVersion)).unsigned=!1:typeof i.modelVersion=="string"?d.modelVersion=parseInt(i.modelVersion,10):typeof i.modelVersion=="number"?d.modelVersion=i.modelVersion:typeof i.modelVersion=="object"&&(d.modelVersion=new f.LongBits(i.modelVersion.low>>>0,i.modelVersion.high>>>0).toNumber())),i.docString!=null&&(d.docString=String(i.docString)),i.graph!=null){if(typeof i.graph!="object")throw TypeError(".onnx.ModelProto.graph: object expected");d.graph=h.onnx.GraphProto.fromObject(i.graph)}if(i.metadataProps){if(!Array.isArray(i.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");for(d.metadataProps=[],p=0;p<i.metadataProps.length;++p){if(typeof i.metadataProps[p]!="object")throw TypeError(".onnx.ModelProto.metadataProps: object expected");d.metadataProps[p]=h.onnx.StringStringEntryProto.fromObject(i.metadataProps[p])}}if(i.trainingInfo){if(!Array.isArray(i.trainingInfo))throw TypeError(".onnx.ModelProto.trainingInfo: array expected");for(d.trainingInfo=[],p=0;p<i.trainingInfo.length;++p){if(typeof i.trainingInfo[p]!="object")throw TypeError(".onnx.ModelProto.trainingInfo: object expected");d.trainingInfo[p]=h.onnx.TrainingInfoProto.fromObject(i.trainingInfo[p])}}if(i.functions){if(!Array.isArray(i.functions))throw TypeError(".onnx.ModelProto.functions: array expected");for(d.functions=[],p=0;p<i.functions.length;++p){if(typeof i.functions[p]!="object")throw TypeError(".onnx.ModelProto.functions: object expected");d.functions[p]=h.onnx.FunctionProto.fromObject(i.functions[p])}}return d},u.toObject=function(i,d){d||(d={});var p={};if((d.arrays||d.defaults)&&(p.opsetImport=[],p.metadataProps=[],p.trainingInfo=[],p.functions=[]),d.defaults){if(f.Long){var _=new f.Long(0,0,!1);p.irVersion=d.longs===String?_.toString():d.longs===Number?_.toNumber():_}else p.irVersion=d.longs===String?"0":0;p.producerName="",p.producerVersion="",p.domain="",f.Long?(_=new f.Long(0,0,!1),p.modelVersion=d.longs===String?_.toString():d.longs===Number?_.toNumber():_):p.modelVersion=d.longs===String?"0":0,p.docString="",p.graph=null}if(i.irVersion!=null&&i.hasOwnProperty("irVersion")&&(typeof i.irVersion=="number"?p.irVersion=d.longs===String?String(i.irVersion):i.irVersion:p.irVersion=d.longs===String?f.Long.prototype.toString.call(i.irVersion):d.longs===Number?new f.LongBits(i.irVersion.low>>>0,i.irVersion.high>>>0).toNumber():i.irVersion),i.producerName!=null&&i.hasOwnProperty("producerName")&&(p.producerName=i.producerName),i.producerVersion!=null&&i.hasOwnProperty("producerVersion")&&(p.producerVersion=i.producerVersion),i.domain!=null&&i.hasOwnProperty("domain")&&(p.domain=i.domain),i.modelVersion!=null&&i.hasOwnProperty("modelVersion")&&(typeof i.modelVersion=="number"?p.modelVersion=d.longs===String?String(i.modelVersion):i.modelVersion:p.modelVersion=d.longs===String?f.Long.prototype.toString.call(i.modelVersion):d.longs===Number?new f.LongBits(i.modelVersion.low>>>0,i.modelVersion.high>>>0).toNumber():i.modelVersion),i.docString!=null&&i.hasOwnProperty("docString")&&(p.docString=i.docString),i.graph!=null&&i.hasOwnProperty("graph")&&(p.graph=h.onnx.GraphProto.toObject(i.graph,d)),i.opsetImport&&i.opsetImport.length){p.opsetImport=[];for(var m=0;m<i.opsetImport.length;++m)p.opsetImport[m]=h.onnx.OperatorSetIdProto.toObject(i.opsetImport[m],d)}if(i.metadataProps&&i.metadataProps.length)for(p.metadataProps=[],m=0;m<i.metadataProps.length;++m)p.metadataProps[m]=h.onnx.StringStringEntryProto.toObject(i.metadataProps[m],d);if(i.trainingInfo&&i.trainingInfo.length)for(p.trainingInfo=[],m=0;m<i.trainingInfo.length;++m)p.trainingInfo[m]=h.onnx.TrainingInfoProto.toObject(i.trainingInfo[m],d);if(i.functions&&i.functions.length)for(p.functions=[],m=0;m<i.functions.length;++m)p.functions[m]=h.onnx.FunctionProto.toObject(i.functions[m],d);return p},u.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},u.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.ModelProto"},u}(),o.StringStringEntryProto=function(){function u(i){if(i)for(var d=Object.keys(i),p=0;p<d.length;++p)i[d[p]]!=null&&(this[d[p]]=i[d[p]])}return u.prototype.key="",u.prototype.value="",u.create=function(i){return new u(i)},u.encode=function(i,d){return d||(d=c.create()),i.key!=null&&Object.hasOwnProperty.call(i,"key")&&d.uint32(10).string(i.key),i.value!=null&&Object.hasOwnProperty.call(i,"value")&&d.uint32(18).string(i.value),d},u.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},u.decode=function(i,d){i instanceof l||(i=l.create(i));for(var p=d===void 0?i.len:i.pos+d,_=new h.onnx.StringStringEntryProto;i.pos<p;){var m=i.uint32();switch(m>>>3){case 1:_.key=i.string();break;case 2:_.value=i.string();break;default:i.skipType(7&m)}}return _},u.decodeDelimited=function(i){return i instanceof l||(i=new l(i)),this.decode(i,i.uint32())},u.verify=function(i){return typeof i!="object"||i===null?"object expected":i.key!=null&&i.hasOwnProperty("key")&&!f.isString(i.key)?"key: string expected":i.value!=null&&i.hasOwnProperty("value")&&!f.isString(i.value)?"value: string expected":null},u.fromObject=function(i){if(i instanceof h.onnx.StringStringEntryProto)return i;var d=new h.onnx.StringStringEntryProto;return i.key!=null&&(d.key=String(i.key)),i.value!=null&&(d.value=String(i.value)),d},u.toObject=function(i,d){d||(d={});var p={};return d.defaults&&(p.key="",p.value=""),i.key!=null&&i.hasOwnProperty("key")&&(p.key=i.key),i.value!=null&&i.hasOwnProperty("value")&&(p.value=i.value),p},u.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},u.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.StringStringEntryProto"},u}(),o.TensorAnnotation=function(){function u(i){if(this.quantParameterTensorNames=[],i)for(var d=Object.keys(i),p=0;p<d.length;++p)i[d[p]]!=null&&(this[d[p]]=i[d[p]])}return u.prototype.tensorName="",u.prototype.quantParameterTensorNames=f.emptyArray,u.create=function(i){return new u(i)},u.encode=function(i,d){if(d||(d=c.create()),i.tensorName!=null&&Object.hasOwnProperty.call(i,"tensorName")&&d.uint32(10).string(i.tensorName),i.quantParameterTensorNames!=null&&i.quantParameterTensorNames.length)for(var p=0;p<i.quantParameterTensorNames.length;++p)h.onnx.StringStringEntryProto.encode(i.quantParameterTensorNames[p],d.uint32(18).fork()).ldelim();return d},u.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},u.decode=function(i,d){i instanceof l||(i=l.create(i));for(var p=d===void 0?i.len:i.pos+d,_=new h.onnx.TensorAnnotation;i.pos<p;){var m=i.uint32();switch(m>>>3){case 1:_.tensorName=i.string();break;case 2:_.quantParameterTensorNames&&_.quantParameterTensorNames.length||(_.quantParameterTensorNames=[]),_.quantParameterTensorNames.push(h.onnx.StringStringEntryProto.decode(i,i.uint32()));break;default:i.skipType(7&m)}}return _},u.decodeDelimited=function(i){return i instanceof l||(i=new l(i)),this.decode(i,i.uint32())},u.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.tensorName!=null&&i.hasOwnProperty("tensorName")&&!f.isString(i.tensorName))return"tensorName: string expected";if(i.quantParameterTensorNames!=null&&i.hasOwnProperty("quantParameterTensorNames")){if(!Array.isArray(i.quantParameterTensorNames))return"quantParameterTensorNames: array expected";for(var d=0;d<i.quantParameterTensorNames.length;++d){var p=h.onnx.StringStringEntryProto.verify(i.quantParameterTensorNames[d]);if(p)return"quantParameterTensorNames."+p}}return null},u.fromObject=function(i){if(i instanceof h.onnx.TensorAnnotation)return i;var d=new h.onnx.TensorAnnotation;if(i.tensorName!=null&&(d.tensorName=String(i.tensorName)),i.quantParameterTensorNames){if(!Array.isArray(i.quantParameterTensorNames))throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: array expected");d.quantParameterTensorNames=[];for(var p=0;p<i.quantParameterTensorNames.length;++p){if(typeof i.quantParameterTensorNames[p]!="object")throw TypeError(".onnx.TensorAnnotation.quantParameterTensorNames: object expected");d.quantParameterTensorNames[p]=h.onnx.StringStringEntryProto.fromObject(i.quantParameterTensorNames[p])}}return d},u.toObject=function(i,d){d||(d={});var p={};if((d.arrays||d.defaults)&&(p.quantParameterTensorNames=[]),d.defaults&&(p.tensorName=""),i.tensorName!=null&&i.hasOwnProperty("tensorName")&&(p.tensorName=i.tensorName),i.quantParameterTensorNames&&i.quantParameterTensorNames.length){p.quantParameterTensorNames=[];for(var _=0;_<i.quantParameterTensorNames.length;++_)p.quantParameterTensorNames[_]=h.onnx.StringStringEntryProto.toObject(i.quantParameterTensorNames[_],d)}return p},u.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},u.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TensorAnnotation"},u}(),o.GraphProto=function(){function u(i){if(this.node=[],this.initializer=[],this.sparseInitializer=[],this.input=[],this.output=[],this.valueInfo=[],this.quantizationAnnotation=[],i)for(var d=Object.keys(i),p=0;p<d.length;++p)i[d[p]]!=null&&(this[d[p]]=i[d[p]])}return u.prototype.node=f.emptyArray,u.prototype.name="",u.prototype.initializer=f.emptyArray,u.prototype.sparseInitializer=f.emptyArray,u.prototype.docString="",u.prototype.input=f.emptyArray,u.prototype.output=f.emptyArray,u.prototype.valueInfo=f.emptyArray,u.prototype.quantizationAnnotation=f.emptyArray,u.create=function(i){return new u(i)},u.encode=function(i,d){if(d||(d=c.create()),i.node!=null&&i.node.length)for(var p=0;p<i.node.length;++p)h.onnx.NodeProto.encode(i.node[p],d.uint32(10).fork()).ldelim();if(i.name!=null&&Object.hasOwnProperty.call(i,"name")&&d.uint32(18).string(i.name),i.initializer!=null&&i.initializer.length)for(p=0;p<i.initializer.length;++p)h.onnx.TensorProto.encode(i.initializer[p],d.uint32(42).fork()).ldelim();if(i.docString!=null&&Object.hasOwnProperty.call(i,"docString")&&d.uint32(82).string(i.docString),i.input!=null&&i.input.length)for(p=0;p<i.input.length;++p)h.onnx.ValueInfoProto.encode(i.input[p],d.uint32(90).fork()).ldelim();if(i.output!=null&&i.output.length)for(p=0;p<i.output.length;++p)h.onnx.ValueInfoProto.encode(i.output[p],d.uint32(98).fork()).ldelim();if(i.valueInfo!=null&&i.valueInfo.length)for(p=0;p<i.valueInfo.length;++p)h.onnx.ValueInfoProto.encode(i.valueInfo[p],d.uint32(106).fork()).ldelim();if(i.quantizationAnnotation!=null&&i.quantizationAnnotation.length)for(p=0;p<i.quantizationAnnotation.length;++p)h.onnx.TensorAnnotation.encode(i.quantizationAnnotation[p],d.uint32(114).fork()).ldelim();if(i.sparseInitializer!=null&&i.sparseInitializer.length)for(p=0;p<i.sparseInitializer.length;++p)h.onnx.SparseTensorProto.encode(i.sparseInitializer[p],d.uint32(122).fork()).ldelim();return d},u.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},u.decode=function(i,d){i instanceof l||(i=l.create(i));for(var p=d===void 0?i.len:i.pos+d,_=new h.onnx.GraphProto;i.pos<p;){var m=i.uint32();switch(m>>>3){case 1:_.node&&_.node.length||(_.node=[]),_.node.push(h.onnx.NodeProto.decode(i,i.uint32()));break;case 2:_.name=i.string();break;case 5:_.initializer&&_.initializer.length||(_.initializer=[]),_.initializer.push(h.onnx.TensorProto.decode(i,i.uint32()));break;case 15:_.sparseInitializer&&_.sparseInitializer.length||(_.sparseInitializer=[]),_.sparseInitializer.push(h.onnx.SparseTensorProto.decode(i,i.uint32()));break;case 10:_.docString=i.string();break;case 11:_.input&&_.input.length||(_.input=[]),_.input.push(h.onnx.ValueInfoProto.decode(i,i.uint32()));break;case 12:_.output&&_.output.length||(_.output=[]),_.output.push(h.onnx.ValueInfoProto.decode(i,i.uint32()));break;case 13:_.valueInfo&&_.valueInfo.length||(_.valueInfo=[]),_.valueInfo.push(h.onnx.ValueInfoProto.decode(i,i.uint32()));break;case 14:_.quantizationAnnotation&&_.quantizationAnnotation.length||(_.quantizationAnnotation=[]),_.quantizationAnnotation.push(h.onnx.TensorAnnotation.decode(i,i.uint32()));break;default:i.skipType(7&m)}}return _},u.decodeDelimited=function(i){return i instanceof l||(i=new l(i)),this.decode(i,i.uint32())},u.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.node!=null&&i.hasOwnProperty("node")){if(!Array.isArray(i.node))return"node: array expected";for(var d=0;d<i.node.length;++d)if(p=h.onnx.NodeProto.verify(i.node[d]))return"node."+p}if(i.name!=null&&i.hasOwnProperty("name")&&!f.isString(i.name))return"name: string expected";if(i.initializer!=null&&i.hasOwnProperty("initializer")){if(!Array.isArray(i.initializer))return"initializer: array expected";for(d=0;d<i.initializer.length;++d)if(p=h.onnx.TensorProto.verify(i.initializer[d]))return"initializer."+p}if(i.sparseInitializer!=null&&i.hasOwnProperty("sparseInitializer")){if(!Array.isArray(i.sparseInitializer))return"sparseInitializer: array expected";for(d=0;d<i.sparseInitializer.length;++d)if(p=h.onnx.SparseTensorProto.verify(i.sparseInitializer[d]))return"sparseInitializer."+p}if(i.docString!=null&&i.hasOwnProperty("docString")&&!f.isString(i.docString))return"docString: string expected";if(i.input!=null&&i.hasOwnProperty("input")){if(!Array.isArray(i.input))return"input: array expected";for(d=0;d<i.input.length;++d)if(p=h.onnx.ValueInfoProto.verify(i.input[d]))return"input."+p}if(i.output!=null&&i.hasOwnProperty("output")){if(!Array.isArray(i.output))return"output: array expected";for(d=0;d<i.output.length;++d)if(p=h.onnx.ValueInfoProto.verify(i.output[d]))return"output."+p}if(i.valueInfo!=null&&i.hasOwnProperty("valueInfo")){if(!Array.isArray(i.valueInfo))return"valueInfo: array expected";for(d=0;d<i.valueInfo.length;++d)if(p=h.onnx.ValueInfoProto.verify(i.valueInfo[d]))return"valueInfo."+p}if(i.quantizationAnnotation!=null&&i.hasOwnProperty("quantizationAnnotation")){if(!Array.isArray(i.quantizationAnnotation))return"quantizationAnnotation: array expected";for(d=0;d<i.quantizationAnnotation.length;++d){var p;if(p=h.onnx.TensorAnnotation.verify(i.quantizationAnnotation[d]))return"quantizationAnnotation."+p}}return null},u.fromObject=function(i){if(i instanceof h.onnx.GraphProto)return i;var d=new h.onnx.GraphProto;if(i.node){if(!Array.isArray(i.node))throw TypeError(".onnx.GraphProto.node: array expected");d.node=[];for(var p=0;p<i.node.length;++p){if(typeof i.node[p]!="object")throw TypeError(".onnx.GraphProto.node: object expected");d.node[p]=h.onnx.NodeProto.fromObject(i.node[p])}}if(i.name!=null&&(d.name=String(i.name)),i.initializer){if(!Array.isArray(i.initializer))throw TypeError(".onnx.GraphProto.initializer: array expected");for(d.initializer=[],p=0;p<i.initializer.length;++p){if(typeof i.initializer[p]!="object")throw TypeError(".onnx.GraphProto.initializer: object expected");d.initializer[p]=h.onnx.TensorProto.fromObject(i.initializer[p])}}if(i.sparseInitializer){if(!Array.isArray(i.sparseInitializer))throw TypeError(".onnx.GraphProto.sparseInitializer: array expected");for(d.sparseInitializer=[],p=0;p<i.sparseInitializer.length;++p){if(typeof i.sparseInitializer[p]!="object")throw TypeError(".onnx.GraphProto.sparseInitializer: object expected");d.sparseInitializer[p]=h.onnx.SparseTensorProto.fromObject(i.sparseInitializer[p])}}if(i.docString!=null&&(d.docString=String(i.docString)),i.input){if(!Array.isArray(i.input))throw TypeError(".onnx.GraphProto.input: array expected");for(d.input=[],p=0;p<i.input.length;++p){if(typeof i.input[p]!="object")throw TypeError(".onnx.GraphProto.input: object expected");d.input[p]=h.onnx.ValueInfoProto.fromObject(i.input[p])}}if(i.output){if(!Array.isArray(i.output))throw TypeError(".onnx.GraphProto.output: array expected");for(d.output=[],p=0;p<i.output.length;++p){if(typeof i.output[p]!="object")throw TypeError(".onnx.GraphProto.output: object expected");d.output[p]=h.onnx.ValueInfoProto.fromObject(i.output[p])}}if(i.valueInfo){if(!Array.isArray(i.valueInfo))throw TypeError(".onnx.GraphProto.valueInfo: array expected");for(d.valueInfo=[],p=0;p<i.valueInfo.length;++p){if(typeof i.valueInfo[p]!="object")throw TypeError(".onnx.GraphProto.valueInfo: object expected");d.valueInfo[p]=h.onnx.ValueInfoProto.fromObject(i.valueInfo[p])}}if(i.quantizationAnnotation){if(!Array.isArray(i.quantizationAnnotation))throw TypeError(".onnx.GraphProto.quantizationAnnotation: array expected");for(d.quantizationAnnotation=[],p=0;p<i.quantizationAnnotation.length;++p){if(typeof i.quantizationAnnotation[p]!="object")throw TypeError(".onnx.GraphProto.quantizationAnnotation: object expected");d.quantizationAnnotation[p]=h.onnx.TensorAnnotation.fromObject(i.quantizationAnnotation[p])}}return d},u.toObject=function(i,d){d||(d={});var p={};if((d.arrays||d.defaults)&&(p.node=[],p.initializer=[],p.input=[],p.output=[],p.valueInfo=[],p.quantizationAnnotation=[],p.sparseInitializer=[]),d.defaults&&(p.name="",p.docString=""),i.node&&i.node.length){p.node=[];for(var _=0;_<i.node.length;++_)p.node[_]=h.onnx.NodeProto.toObject(i.node[_],d)}if(i.name!=null&&i.hasOwnProperty("name")&&(p.name=i.name),i.initializer&&i.initializer.length)for(p.initializer=[],_=0;_<i.initializer.length;++_)p.initializer[_]=h.onnx.TensorProto.toObject(i.initializer[_],d);if(i.docString!=null&&i.hasOwnProperty("docString")&&(p.docString=i.docString),i.input&&i.input.length)for(p.input=[],_=0;_<i.input.length;++_)p.input[_]=h.onnx.ValueInfoProto.toObject(i.input[_],d);if(i.output&&i.output.length)for(p.output=[],_=0;_<i.output.length;++_)p.output[_]=h.onnx.ValueInfoProto.toObject(i.output[_],d);if(i.valueInfo&&i.valueInfo.length)for(p.valueInfo=[],_=0;_<i.valueInfo.length;++_)p.valueInfo[_]=h.onnx.ValueInfoProto.toObject(i.valueInfo[_],d);if(i.quantizationAnnotation&&i.quantizationAnnotation.length)for(p.quantizationAnnotation=[],_=0;_<i.quantizationAnnotation.length;++_)p.quantizationAnnotation[_]=h.onnx.TensorAnnotation.toObject(i.quantizationAnnotation[_],d);if(i.sparseInitializer&&i.sparseInitializer.length)for(p.sparseInitializer=[],_=0;_<i.sparseInitializer.length;++_)p.sparseInitializer[_]=h.onnx.SparseTensorProto.toObject(i.sparseInitializer[_],d);return p},u.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},u.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.GraphProto"},u}(),o.TensorProto=function(){function u(i){if(this.dims=[],this.floatData=[],this.int32Data=[],this.stringData=[],this.int64Data=[],this.externalData=[],this.doubleData=[],this.uint64Data=[],i)for(var d=Object.keys(i),p=0;p<d.length;++p)i[d[p]]!=null&&(this[d[p]]=i[d[p]])}return u.prototype.dims=f.emptyArray,u.prototype.dataType=0,u.prototype.segment=null,u.prototype.floatData=f.emptyArray,u.prototype.int32Data=f.emptyArray,u.prototype.stringData=f.emptyArray,u.prototype.int64Data=f.emptyArray,u.prototype.name="",u.prototype.docString="",u.prototype.rawData=f.newBuffer([]),u.prototype.externalData=f.emptyArray,u.prototype.dataLocation=0,u.prototype.doubleData=f.emptyArray,u.prototype.uint64Data=f.emptyArray,u.create=function(i){return new u(i)},u.encode=function(i,d){if(d||(d=c.create()),i.dims!=null&&i.dims.length){d.uint32(10).fork();for(var p=0;p<i.dims.length;++p)d.int64(i.dims[p]);d.ldelim()}if(i.dataType!=null&&Object.hasOwnProperty.call(i,"dataType")&&d.uint32(16).int32(i.dataType),i.segment!=null&&Object.hasOwnProperty.call(i,"segment")&&h.onnx.TensorProto.Segment.encode(i.segment,d.uint32(26).fork()).ldelim(),i.floatData!=null&&i.floatData.length){for(d.uint32(34).fork(),p=0;p<i.floatData.length;++p)d.float(i.floatData[p]);d.ldelim()}if(i.int32Data!=null&&i.int32Data.length){for(d.uint32(42).fork(),p=0;p<i.int32Data.length;++p)d.int32(i.int32Data[p]);d.ldelim()}if(i.stringData!=null&&i.stringData.length)for(p=0;p<i.stringData.length;++p)d.uint32(50).bytes(i.stringData[p]);if(i.int64Data!=null&&i.int64Data.length){for(d.uint32(58).fork(),p=0;p<i.int64Data.length;++p)d.int64(i.int64Data[p]);d.ldelim()}if(i.name!=null&&Object.hasOwnProperty.call(i,"name")&&d.uint32(66).string(i.name),i.rawData!=null&&Object.hasOwnProperty.call(i,"rawData")&&d.uint32(74).bytes(i.rawData),i.doubleData!=null&&i.doubleData.length){for(d.uint32(82).fork(),p=0;p<i.doubleData.length;++p)d.double(i.doubleData[p]);d.ldelim()}if(i.uint64Data!=null&&i.uint64Data.length){for(d.uint32(90).fork(),p=0;p<i.uint64Data.length;++p)d.uint64(i.uint64Data[p]);d.ldelim()}if(i.docString!=null&&Object.hasOwnProperty.call(i,"docString")&&d.uint32(98).string(i.docString),i.externalData!=null&&i.externalData.length)for(p=0;p<i.externalData.length;++p)h.onnx.StringStringEntryProto.encode(i.externalData[p],d.uint32(106).fork()).ldelim();return i.dataLocation!=null&&Object.hasOwnProperty.call(i,"dataLocation")&&d.uint32(112).int32(i.dataLocation),d},u.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},u.decode=function(i,d){i instanceof l||(i=l.create(i));for(var p=d===void 0?i.len:i.pos+d,_=new h.onnx.TensorProto;i.pos<p;){var m=i.uint32();switch(m>>>3){case 1:if(_.dims&&_.dims.length||(_.dims=[]),(7&m)==2)for(var g=i.uint32()+i.pos;i.pos<g;)_.dims.push(i.int64());else _.dims.push(i.int64());break;case 2:_.dataType=i.int32();break;case 3:_.segment=h.onnx.TensorProto.Segment.decode(i,i.uint32());break;case 4:if(_.floatData&&_.floatData.length||(_.floatData=[]),(7&m)==2)for(g=i.uint32()+i.pos;i.pos<g;)_.floatData.push(i.float());else _.floatData.push(i.float());break;case 5:if(_.int32Data&&_.int32Data.length||(_.int32Data=[]),(7&m)==2)for(g=i.uint32()+i.pos;i.pos<g;)_.int32Data.push(i.int32());else _.int32Data.push(i.int32());break;case 6:_.stringData&&_.stringData.length||(_.stringData=[]),_.stringData.push(i.bytes());break;case 7:if(_.int64Data&&_.int64Data.length||(_.int64Data=[]),(7&m)==2)for(g=i.uint32()+i.pos;i.pos<g;)_.int64Data.push(i.int64());else _.int64Data.push(i.int64());break;case 8:_.name=i.string();break;case 12:_.docString=i.string();break;case 9:_.rawData=i.bytes();break;case 13:_.externalData&&_.externalData.length||(_.externalData=[]),_.externalData.push(h.onnx.StringStringEntryProto.decode(i,i.uint32()));break;case 14:_.dataLocation=i.int32();break;case 10:if(_.doubleData&&_.doubleData.length||(_.doubleData=[]),(7&m)==2)for(g=i.uint32()+i.pos;i.pos<g;)_.doubleData.push(i.double());else _.doubleData.push(i.double());break;case 11:if(_.uint64Data&&_.uint64Data.length||(_.uint64Data=[]),(7&m)==2)for(g=i.uint32()+i.pos;i.pos<g;)_.uint64Data.push(i.uint64());else _.uint64Data.push(i.uint64());break;default:i.skipType(7&m)}}return _},u.decodeDelimited=function(i){return i instanceof l||(i=new l(i)),this.decode(i,i.uint32())},u.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.dims!=null&&i.hasOwnProperty("dims")){if(!Array.isArray(i.dims))return"dims: array expected";for(var d=0;d<i.dims.length;++d)if(!(f.isInteger(i.dims[d])||i.dims[d]&&f.isInteger(i.dims[d].low)&&f.isInteger(i.dims[d].high)))return"dims: integer|Long[] expected"}if(i.dataType!=null&&i.hasOwnProperty("dataType")&&!f.isInteger(i.dataType))return"dataType: integer expected";if(i.segment!=null&&i.hasOwnProperty("segment")&&(p=h.onnx.TensorProto.Segment.verify(i.segment)))return"segment."+p;if(i.floatData!=null&&i.hasOwnProperty("floatData")){if(!Array.isArray(i.floatData))return"floatData: array expected";for(d=0;d<i.floatData.length;++d)if(typeof i.floatData[d]!="number")return"floatData: number[] expected"}if(i.int32Data!=null&&i.hasOwnProperty("int32Data")){if(!Array.isArray(i.int32Data))return"int32Data: array expected";for(d=0;d<i.int32Data.length;++d)if(!f.isInteger(i.int32Data[d]))return"int32Data: integer[] expected"}if(i.stringData!=null&&i.hasOwnProperty("stringData")){if(!Array.isArray(i.stringData))return"stringData: array expected";for(d=0;d<i.stringData.length;++d)if(!(i.stringData[d]&&typeof i.stringData[d].length=="number"||f.isString(i.stringData[d])))return"stringData: buffer[] expected"}if(i.int64Data!=null&&i.hasOwnProperty("int64Data")){if(!Array.isArray(i.int64Data))return"int64Data: array expected";for(d=0;d<i.int64Data.length;++d)if(!(f.isInteger(i.int64Data[d])||i.int64Data[d]&&f.isInteger(i.int64Data[d].low)&&f.isInteger(i.int64Data[d].high)))return"int64Data: integer|Long[] expected"}if(i.name!=null&&i.hasOwnProperty("name")&&!f.isString(i.name))return"name: string expected";if(i.docString!=null&&i.hasOwnProperty("docString")&&!f.isString(i.docString))return"docString: string expected";if(i.rawData!=null&&i.hasOwnProperty("rawData")&&!(i.rawData&&typeof i.rawData.length=="number"||f.isString(i.rawData)))return"rawData: buffer expected";if(i.externalData!=null&&i.hasOwnProperty("externalData")){if(!Array.isArray(i.externalData))return"externalData: array expected";for(d=0;d<i.externalData.length;++d){var p;if(p=h.onnx.StringStringEntryProto.verify(i.externalData[d]))return"externalData."+p}}if(i.dataLocation!=null&&i.hasOwnProperty("dataLocation"))switch(i.dataLocation){default:return"dataLocation: enum value expected";case 0:case 1:}if(i.doubleData!=null&&i.hasOwnProperty("doubleData")){if(!Array.isArray(i.doubleData))return"doubleData: array expected";for(d=0;d<i.doubleData.length;++d)if(typeof i.doubleData[d]!="number")return"doubleData: number[] expected"}if(i.uint64Data!=null&&i.hasOwnProperty("uint64Data")){if(!Array.isArray(i.uint64Data))return"uint64Data: array expected";for(d=0;d<i.uint64Data.length;++d)if(!(f.isInteger(i.uint64Data[d])||i.uint64Data[d]&&f.isInteger(i.uint64Data[d].low)&&f.isInteger(i.uint64Data[d].high)))return"uint64Data: integer|Long[] expected"}return null},u.fromObject=function(i){if(i instanceof h.onnx.TensorProto)return i;var d=new h.onnx.TensorProto;if(i.dims){if(!Array.isArray(i.dims))throw TypeError(".onnx.TensorProto.dims: array expected");d.dims=[];for(var p=0;p<i.dims.length;++p)f.Long?(d.dims[p]=f.Long.fromValue(i.dims[p])).unsigned=!1:typeof i.dims[p]=="string"?d.dims[p]=parseInt(i.dims[p],10):typeof i.dims[p]=="number"?d.dims[p]=i.dims[p]:typeof i.dims[p]=="object"&&(d.dims[p]=new f.LongBits(i.dims[p].low>>>0,i.dims[p].high>>>0).toNumber())}if(i.dataType!=null&&(d.dataType=0|i.dataType),i.segment!=null){if(typeof i.segment!="object")throw TypeError(".onnx.TensorProto.segment: object expected");d.segment=h.onnx.TensorProto.Segment.fromObject(i.segment)}if(i.floatData){if(!Array.isArray(i.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");for(d.floatData=[],p=0;p<i.floatData.length;++p)d.floatData[p]=Number(i.floatData[p])}if(i.int32Data){if(!Array.isArray(i.int32Data))throw TypeError(".onnx.TensorProto.int32Data: array expected");for(d.int32Data=[],p=0;p<i.int32Data.length;++p)d.int32Data[p]=0|i.int32Data[p]}if(i.stringData){if(!Array.isArray(i.stringData))throw TypeError(".onnx.TensorProto.stringData: array expected");for(d.stringData=[],p=0;p<i.stringData.length;++p)typeof i.stringData[p]=="string"?f.base64.decode(i.stringData[p],d.stringData[p]=f.newBuffer(f.base64.length(i.stringData[p])),0):i.stringData[p].length>=0&&(d.stringData[p]=i.stringData[p])}if(i.int64Data){if(!Array.isArray(i.int64Data))throw TypeError(".onnx.TensorProto.int64Data: array expected");for(d.int64Data=[],p=0;p<i.int64Data.length;++p)f.Long?(d.int64Data[p]=f.Long.fromValue(i.int64Data[p])).unsigned=!1:typeof i.int64Data[p]=="string"?d.int64Data[p]=parseInt(i.int64Data[p],10):typeof i.int64Data[p]=="number"?d.int64Data[p]=i.int64Data[p]:typeof i.int64Data[p]=="object"&&(d.int64Data[p]=new f.LongBits(i.int64Data[p].low>>>0,i.int64Data[p].high>>>0).toNumber())}if(i.name!=null&&(d.name=String(i.name)),i.docString!=null&&(d.docString=String(i.docString)),i.rawData!=null&&(typeof i.rawData=="string"?f.base64.decode(i.rawData,d.rawData=f.newBuffer(f.base64.length(i.rawData)),0):i.rawData.length>=0&&(d.rawData=i.rawData)),i.externalData){if(!Array.isArray(i.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");for(d.externalData=[],p=0;p<i.externalData.length;++p){if(typeof i.externalData[p]!="object")throw TypeError(".onnx.TensorProto.externalData: object expected");d.externalData[p]=h.onnx.StringStringEntryProto.fromObject(i.externalData[p])}}switch(i.dataLocation){default:if(typeof i.dataLocation=="number"){d.dataLocation=i.dataLocation;break}break;case"DEFAULT":case 0:d.dataLocation=0;break;case"EXTERNAL":case 1:d.dataLocation=1}if(i.doubleData){if(!Array.isArray(i.doubleData))throw TypeError(".onnx.TensorProto.doubleData: array expected");for(d.doubleData=[],p=0;p<i.doubleData.length;++p)d.doubleData[p]=Number(i.doubleData[p])}if(i.uint64Data){if(!Array.isArray(i.uint64Data))throw TypeError(".onnx.TensorProto.uint64Data: array expected");for(d.uint64Data=[],p=0;p<i.uint64Data.length;++p)f.Long?(d.uint64Data[p]=f.Long.fromValue(i.uint64Data[p])).unsigned=!0:typeof i.uint64Data[p]=="string"?d.uint64Data[p]=parseInt(i.uint64Data[p],10):typeof i.uint64Data[p]=="number"?d.uint64Data[p]=i.uint64Data[p]:typeof i.uint64Data[p]=="object"&&(d.uint64Data[p]=new f.LongBits(i.uint64Data[p].low>>>0,i.uint64Data[p].high>>>0).toNumber(!0))}return d},u.toObject=function(i,d){d||(d={});var p={};if((d.arrays||d.defaults)&&(p.dims=[],p.floatData=[],p.int32Data=[],p.stringData=[],p.int64Data=[],p.doubleData=[],p.uint64Data=[],p.externalData=[]),d.defaults&&(p.dataType=0,p.segment=null,p.name="",d.bytes===String?p.rawData="":(p.rawData=[],d.bytes!==Array&&(p.rawData=f.newBuffer(p.rawData))),p.docString="",p.dataLocation=d.enums===String?"DEFAULT":0),i.dims&&i.dims.length){p.dims=[];for(var _=0;_<i.dims.length;++_)typeof i.dims[_]=="number"?p.dims[_]=d.longs===String?String(i.dims[_]):i.dims[_]:p.dims[_]=d.longs===String?f.Long.prototype.toString.call(i.dims[_]):d.longs===Number?new f.LongBits(i.dims[_].low>>>0,i.dims[_].high>>>0).toNumber():i.dims[_]}if(i.dataType!=null&&i.hasOwnProperty("dataType")&&(p.dataType=i.dataType),i.segment!=null&&i.hasOwnProperty("segment")&&(p.segment=h.onnx.TensorProto.Segment.toObject(i.segment,d)),i.floatData&&i.floatData.length)for(p.floatData=[],_=0;_<i.floatData.length;++_)p.floatData[_]=d.json&&!isFinite(i.floatData[_])?String(i.floatData[_]):i.floatData[_];if(i.int32Data&&i.int32Data.length)for(p.int32Data=[],_=0;_<i.int32Data.length;++_)p.int32Data[_]=i.int32Data[_];if(i.stringData&&i.stringData.length)for(p.stringData=[],_=0;_<i.stringData.length;++_)p.stringData[_]=d.bytes===String?f.base64.encode(i.stringData[_],0,i.stringData[_].length):d.bytes===Array?Array.prototype.slice.call(i.stringData[_]):i.stringData[_];if(i.int64Data&&i.int64Data.length)for(p.int64Data=[],_=0;_<i.int64Data.length;++_)typeof i.int64Data[_]=="number"?p.int64Data[_]=d.longs===String?String(i.int64Data[_]):i.int64Data[_]:p.int64Data[_]=d.longs===String?f.Long.prototype.toString.call(i.int64Data[_]):d.longs===Number?new f.LongBits(i.int64Data[_].low>>>0,i.int64Data[_].high>>>0).toNumber():i.int64Data[_];if(i.name!=null&&i.hasOwnProperty("name")&&(p.name=i.name),i.rawData!=null&&i.hasOwnProperty("rawData")&&(p.rawData=d.bytes===String?f.base64.encode(i.rawData,0,i.rawData.length):d.bytes===Array?Array.prototype.slice.call(i.rawData):i.rawData),i.doubleData&&i.doubleData.length)for(p.doubleData=[],_=0;_<i.doubleData.length;++_)p.doubleData[_]=d.json&&!isFinite(i.doubleData[_])?String(i.doubleData[_]):i.doubleData[_];if(i.uint64Data&&i.uint64Data.length)for(p.uint64Data=[],_=0;_<i.uint64Data.length;++_)typeof i.uint64Data[_]=="number"?p.uint64Data[_]=d.longs===String?String(i.uint64Data[_]):i.uint64Data[_]:p.uint64Data[_]=d.longs===String?f.Long.prototype.toString.call(i.uint64Data[_]):d.longs===Number?new f.LongBits(i.uint64Data[_].low>>>0,i.uint64Data[_].high>>>0).toNumber(!0):i.uint64Data[_];if(i.docString!=null&&i.hasOwnProperty("docString")&&(p.docString=i.docString),i.externalData&&i.externalData.length)for(p.externalData=[],_=0;_<i.externalData.length;++_)p.externalData[_]=h.onnx.StringStringEntryProto.toObject(i.externalData[_],d);return i.dataLocation!=null&&i.hasOwnProperty("dataLocation")&&(p.dataLocation=d.enums===String?h.onnx.TensorProto.DataLocation[i.dataLocation]===void 0?i.dataLocation:h.onnx.TensorProto.DataLocation[i.dataLocation]:i.dataLocation),p},u.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},u.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TensorProto"},u.DataType=function(){var i={},d=Object.create(i);return d[i[0]="UNDEFINED"]=0,d[i[1]="FLOAT"]=1,d[i[2]="UINT8"]=2,d[i[3]="INT8"]=3,d[i[4]="UINT16"]=4,d[i[5]="INT16"]=5,d[i[6]="INT32"]=6,d[i[7]="INT64"]=7,d[i[8]="STRING"]=8,d[i[9]="BOOL"]=9,d[i[10]="FLOAT16"]=10,d[i[11]="DOUBLE"]=11,d[i[12]="UINT32"]=12,d[i[13]="UINT64"]=13,d[i[14]="COMPLEX64"]=14,d[i[15]="COMPLEX128"]=15,d[i[16]="BFLOAT16"]=16,d[i[17]="FLOAT8E4M3FN"]=17,d[i[18]="FLOAT8E4M3FNUZ"]=18,d[i[19]="FLOAT8E5M2"]=19,d[i[20]="FLOAT8E5M2FNUZ"]=20,d}(),u.Segment=function(){function i(d){if(d)for(var p=Object.keys(d),_=0;_<p.length;++_)d[p[_]]!=null&&(this[p[_]]=d[p[_]])}return i.prototype.begin=f.Long?f.Long.fromBits(0,0,!1):0,i.prototype.end=f.Long?f.Long.fromBits(0,0,!1):0,i.create=function(d){return new i(d)},i.encode=function(d,p){return p||(p=c.create()),d.begin!=null&&Object.hasOwnProperty.call(d,"begin")&&p.uint32(8).int64(d.begin),d.end!=null&&Object.hasOwnProperty.call(d,"end")&&p.uint32(16).int64(d.end),p},i.encodeDelimited=function(d,p){return this.encode(d,p).ldelim()},i.decode=function(d,p){d instanceof l||(d=l.create(d));for(var _=p===void 0?d.len:d.pos+p,m=new h.onnx.TensorProto.Segment;d.pos<_;){var g=d.uint32();switch(g>>>3){case 1:m.begin=d.int64();break;case 2:m.end=d.int64();break;default:d.skipType(7&g)}}return m},i.decodeDelimited=function(d){return d instanceof l||(d=new l(d)),this.decode(d,d.uint32())},i.verify=function(d){return typeof d!="object"||d===null?"object expected":d.begin!=null&&d.hasOwnProperty("begin")&&!(f.isInteger(d.begin)||d.begin&&f.isInteger(d.begin.low)&&f.isInteger(d.begin.high))?"begin: integer|Long expected":d.end!=null&&d.hasOwnProperty("end")&&!(f.isInteger(d.end)||d.end&&f.isInteger(d.end.low)&&f.isInteger(d.end.high))?"end: integer|Long expected":null},i.fromObject=function(d){if(d instanceof h.onnx.TensorProto.Segment)return d;var p=new h.onnx.TensorProto.Segment;return d.begin!=null&&(f.Long?(p.begin=f.Long.fromValue(d.begin)).unsigned=!1:typeof d.begin=="string"?p.begin=parseInt(d.begin,10):typeof d.begin=="number"?p.begin=d.begin:typeof d.begin=="object"&&(p.begin=new f.LongBits(d.begin.low>>>0,d.begin.high>>>0).toNumber())),d.end!=null&&(f.Long?(p.end=f.Long.fromValue(d.end)).unsigned=!1:typeof d.end=="string"?p.end=parseInt(d.end,10):typeof d.end=="number"?p.end=d.end:typeof d.end=="object"&&(p.end=new f.LongBits(d.end.low>>>0,d.end.high>>>0).toNumber())),p},i.toObject=function(d,p){p||(p={});var _={};if(p.defaults){if(f.Long){var m=new f.Long(0,0,!1);_.begin=p.longs===String?m.toString():p.longs===Number?m.toNumber():m}else _.begin=p.longs===String?"0":0;f.Long?(m=new f.Long(0,0,!1),_.end=p.longs===String?m.toString():p.longs===Number?m.toNumber():m):_.end=p.longs===String?"0":0}return d.begin!=null&&d.hasOwnProperty("begin")&&(typeof d.begin=="number"?_.begin=p.longs===String?String(d.begin):d.begin:_.begin=p.longs===String?f.Long.prototype.toString.call(d.begin):p.longs===Number?new f.LongBits(d.begin.low>>>0,d.begin.high>>>0).toNumber():d.begin),d.end!=null&&d.hasOwnProperty("end")&&(typeof d.end=="number"?_.end=p.longs===String?String(d.end):d.end:_.end=p.longs===String?f.Long.prototype.toString.call(d.end):p.longs===Number?new f.LongBits(d.end.low>>>0,d.end.high>>>0).toNumber():d.end),_},i.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},i.getTypeUrl=function(d){return d===void 0&&(d="type.googleapis.com"),d+"/onnx.TensorProto.Segment"},i}(),u.DataLocation=function(){var i={},d=Object.create(i);return d[i[0]="DEFAULT"]=0,d[i[1]="EXTERNAL"]=1,d}(),u}(),o.SparseTensorProto=function(){function u(i){if(this.dims=[],i)for(var d=Object.keys(i),p=0;p<d.length;++p)i[d[p]]!=null&&(this[d[p]]=i[d[p]])}return u.prototype.values=null,u.prototype.indices=null,u.prototype.dims=f.emptyArray,u.create=function(i){return new u(i)},u.encode=function(i,d){if(d||(d=c.create()),i.values!=null&&Object.hasOwnProperty.call(i,"values")&&h.onnx.TensorProto.encode(i.values,d.uint32(10).fork()).ldelim(),i.indices!=null&&Object.hasOwnProperty.call(i,"indices")&&h.onnx.TensorProto.encode(i.indices,d.uint32(18).fork()).ldelim(),i.dims!=null&&i.dims.length){d.uint32(26).fork();for(var p=0;p<i.dims.length;++p)d.int64(i.dims[p]);d.ldelim()}return d},u.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},u.decode=function(i,d){i instanceof l||(i=l.create(i));for(var p=d===void 0?i.len:i.pos+d,_=new h.onnx.SparseTensorProto;i.pos<p;){var m=i.uint32();switch(m>>>3){case 1:_.values=h.onnx.TensorProto.decode(i,i.uint32());break;case 2:_.indices=h.onnx.TensorProto.decode(i,i.uint32());break;case 3:if(_.dims&&_.dims.length||(_.dims=[]),(7&m)==2)for(var g=i.uint32()+i.pos;i.pos<g;)_.dims.push(i.int64());else _.dims.push(i.int64());break;default:i.skipType(7&m)}}return _},u.decodeDelimited=function(i){return i instanceof l||(i=new l(i)),this.decode(i,i.uint32())},u.verify=function(i){if(typeof i!="object"||i===null)return"object expected";var d;if(i.values!=null&&i.hasOwnProperty("values")&&(d=h.onnx.TensorProto.verify(i.values)))return"values."+d;if(i.indices!=null&&i.hasOwnProperty("indices")&&(d=h.onnx.TensorProto.verify(i.indices)))return"indices."+d;if(i.dims!=null&&i.hasOwnProperty("dims")){if(!Array.isArray(i.dims))return"dims: array expected";for(var p=0;p<i.dims.length;++p)if(!(f.isInteger(i.dims[p])||i.dims[p]&&f.isInteger(i.dims[p].low)&&f.isInteger(i.dims[p].high)))return"dims: integer|Long[] expected"}return null},u.fromObject=function(i){if(i instanceof h.onnx.SparseTensorProto)return i;var d=new h.onnx.SparseTensorProto;if(i.values!=null){if(typeof i.values!="object")throw TypeError(".onnx.SparseTensorProto.values: object expected");d.values=h.onnx.TensorProto.fromObject(i.values)}if(i.indices!=null){if(typeof i.indices!="object")throw TypeError(".onnx.SparseTensorProto.indices: object expected");d.indices=h.onnx.TensorProto.fromObject(i.indices)}if(i.dims){if(!Array.isArray(i.dims))throw TypeError(".onnx.SparseTensorProto.dims: array expected");d.dims=[];for(var p=0;p<i.dims.length;++p)f.Long?(d.dims[p]=f.Long.fromValue(i.dims[p])).unsigned=!1:typeof i.dims[p]=="string"?d.dims[p]=parseInt(i.dims[p],10):typeof i.dims[p]=="number"?d.dims[p]=i.dims[p]:typeof i.dims[p]=="object"&&(d.dims[p]=new f.LongBits(i.dims[p].low>>>0,i.dims[p].high>>>0).toNumber())}return d},u.toObject=function(i,d){d||(d={});var p={};if((d.arrays||d.defaults)&&(p.dims=[]),d.defaults&&(p.values=null,p.indices=null),i.values!=null&&i.hasOwnProperty("values")&&(p.values=h.onnx.TensorProto.toObject(i.values,d)),i.indices!=null&&i.hasOwnProperty("indices")&&(p.indices=h.onnx.TensorProto.toObject(i.indices,d)),i.dims&&i.dims.length){p.dims=[];for(var _=0;_<i.dims.length;++_)typeof i.dims[_]=="number"?p.dims[_]=d.longs===String?String(i.dims[_]):i.dims[_]:p.dims[_]=d.longs===String?f.Long.prototype.toString.call(i.dims[_]):d.longs===Number?new f.LongBits(i.dims[_].low>>>0,i.dims[_].high>>>0).toNumber():i.dims[_]}return p},u.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},u.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.SparseTensorProto"},u}(),o.TensorShapeProto=function(){function u(i){if(this.dim=[],i)for(var d=Object.keys(i),p=0;p<d.length;++p)i[d[p]]!=null&&(this[d[p]]=i[d[p]])}return u.prototype.dim=f.emptyArray,u.create=function(i){return new u(i)},u.encode=function(i,d){if(d||(d=c.create()),i.dim!=null&&i.dim.length)for(var p=0;p<i.dim.length;++p)h.onnx.TensorShapeProto.Dimension.encode(i.dim[p],d.uint32(10).fork()).ldelim();return d},u.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},u.decode=function(i,d){i instanceof l||(i=l.create(i));for(var p=d===void 0?i.len:i.pos+d,_=new h.onnx.TensorShapeProto;i.pos<p;){var m=i.uint32();m>>>3==1?(_.dim&&_.dim.length||(_.dim=[]),_.dim.push(h.onnx.TensorShapeProto.Dimension.decode(i,i.uint32()))):i.skipType(7&m)}return _},u.decodeDelimited=function(i){return i instanceof l||(i=new l(i)),this.decode(i,i.uint32())},u.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.dim!=null&&i.hasOwnProperty("dim")){if(!Array.isArray(i.dim))return"dim: array expected";for(var d=0;d<i.dim.length;++d){var p=h.onnx.TensorShapeProto.Dimension.verify(i.dim[d]);if(p)return"dim."+p}}return null},u.fromObject=function(i){if(i instanceof h.onnx.TensorShapeProto)return i;var d=new h.onnx.TensorShapeProto;if(i.dim){if(!Array.isArray(i.dim))throw TypeError(".onnx.TensorShapeProto.dim: array expected");d.dim=[];for(var p=0;p<i.dim.length;++p){if(typeof i.dim[p]!="object")throw TypeError(".onnx.TensorShapeProto.dim: object expected");d.dim[p]=h.onnx.TensorShapeProto.Dimension.fromObject(i.dim[p])}}return d},u.toObject=function(i,d){d||(d={});var p={};if((d.arrays||d.defaults)&&(p.dim=[]),i.dim&&i.dim.length){p.dim=[];for(var _=0;_<i.dim.length;++_)p.dim[_]=h.onnx.TensorShapeProto.Dimension.toObject(i.dim[_],d)}return p},u.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},u.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.TensorShapeProto"},u.Dimension=function(){function i(p){if(p)for(var _=Object.keys(p),m=0;m<_.length;++m)p[_[m]]!=null&&(this[_[m]]=p[_[m]])}var d;return i.prototype.dimValue=null,i.prototype.dimParam=null,i.prototype.denotation="",Object.defineProperty(i.prototype,"value",{get:f.oneOfGetter(d=["dimValue","dimParam"]),set:f.oneOfSetter(d)}),i.create=function(p){return new i(p)},i.encode=function(p,_){return _||(_=c.create()),p.dimValue!=null&&Object.hasOwnProperty.call(p,"dimValue")&&_.uint32(8).int64(p.dimValue),p.dimParam!=null&&Object.hasOwnProperty.call(p,"dimParam")&&_.uint32(18).string(p.dimParam),p.denotation!=null&&Object.hasOwnProperty.call(p,"denotation")&&_.uint32(26).string(p.denotation),_},i.encodeDelimited=function(p,_){return this.encode(p,_).ldelim()},i.decode=function(p,_){p instanceof l||(p=l.create(p));for(var m=_===void 0?p.len:p.pos+_,g=new h.onnx.TensorShapeProto.Dimension;p.pos<m;){var b=p.uint32();switch(b>>>3){case 1:g.dimValue=p.int64();break;case 2:g.dimParam=p.string();break;case 3:g.denotation=p.string();break;default:p.skipType(7&b)}}return g},i.decodeDelimited=function(p){return p instanceof l||(p=new l(p)),this.decode(p,p.uint32())},i.verify=function(p){if(typeof p!="object"||p===null)return"object expected";var _={};if(p.dimValue!=null&&p.hasOwnProperty("dimValue")&&(_.value=1,!(f.isInteger(p.dimValue)||p.dimValue&&f.isInteger(p.dimValue.low)&&f.isInteger(p.dimValue.high))))return"dimValue: integer|Long expected";if(p.dimParam!=null&&p.hasOwnProperty("dimParam")){if(_.value===1)return"value: multiple values";if(_.value=1,!f.isString(p.dimParam))return"dimParam: string expected"}return p.denotation!=null&&p.hasOwnProperty("denotation")&&!f.isString(p.denotation)?"denotation: string expected":null},i.fromObject=function(p){if(p instanceof h.onnx.TensorShapeProto.Dimension)return p;var _=new h.onnx.TensorShapeProto.Dimension;return p.dimValue!=null&&(f.Long?(_.dimValue=f.Long.fromValue(p.dimValue)).unsigned=!1:typeof p.dimValue=="string"?_.dimValue=parseInt(p.dimValue,10):typeof p.dimValue=="number"?_.dimValue=p.dimValue:typeof p.dimValue=="object"&&(_.dimValue=new f.LongBits(p.dimValue.low>>>0,p.dimValue.high>>>0).toNumber())),p.dimParam!=null&&(_.dimParam=String(p.dimParam)),p.denotation!=null&&(_.denotation=String(p.denotation)),_},i.toObject=function(p,_){_||(_={});var m={};return _.defaults&&(m.denotation=""),p.dimValue!=null&&p.hasOwnProperty("dimValue")&&(typeof p.dimValue=="number"?m.dimValue=_.longs===String?String(p.dimValue):p.dimValue:m.dimValue=_.longs===String?f.Long.prototype.toString.call(p.dimValue):_.longs===Number?new f.LongBits(p.dimValue.low>>>0,p.dimValue.high>>>0).toNumber():p.dimValue,_.oneofs&&(m.value="dimValue")),p.dimParam!=null&&p.hasOwnProperty("dimParam")&&(m.dimParam=p.dimParam,_.oneofs&&(m.value="dimParam")),p.denotation!=null&&p.hasOwnProperty("denotation")&&(m.denotation=p.denotation),m},i.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},i.getTypeUrl=function(p){return p===void 0&&(p="type.googleapis.com"),p+"/onnx.TensorShapeProto.Dimension"},i}(),u}(),o.TypeProto=function(){function u(d){if(d)for(var p=Object.keys(d),_=0;_<p.length;++_)d[p[_]]!=null&&(this[p[_]]=d[p[_]])}var i;return u.prototype.tensorType=null,u.prototype.sequenceType=null,u.prototype.mapType=null,u.prototype.optionalType=null,u.prototype.sparseTensorType=null,u.prototype.denotation="",Object.defineProperty(u.prototype,"value",{get:f.oneOfGetter(i=["tensorType","sequenceType","mapType","optionalType","sparseTensorType"]),set:f.oneOfSetter(i)}),u.create=function(d){return new u(d)},u.encode=function(d,p){return p||(p=c.create()),d.tensorType!=null&&Object.hasOwnProperty.call(d,"tensorType")&&h.onnx.TypeProto.Tensor.encode(d.tensorType,p.uint32(10).fork()).ldelim(),d.sequenceType!=null&&Object.hasOwnProperty.call(d,"sequenceType")&&h.onnx.TypeProto.Sequence.encode(d.sequenceType,p.uint32(34).fork()).ldelim(),d.mapType!=null&&Object.hasOwnProperty.call(d,"mapType")&&h.onnx.TypeProto.Map.encode(d.mapType,p.uint32(42).fork()).ldelim(),d.denotation!=null&&Object.hasOwnProperty.call(d,"denotation")&&p.uint32(50).string(d.denotation),d.sparseTensorType!=null&&Object.hasOwnProperty.call(d,"sparseTensorType")&&h.onnx.TypeProto.SparseTensor.encode(d.sparseTensorType,p.uint32(66).fork()).ldelim(),d.optionalType!=null&&Object.hasOwnProperty.call(d,"optionalType")&&h.onnx.TypeProto.Optional.encode(d.optionalType,p.uint32(74).fork()).ldelim(),p},u.encodeDelimited=function(d,p){return this.encode(d,p).ldelim()},u.decode=function(d,p){d instanceof l||(d=l.create(d));for(var _=p===void 0?d.len:d.pos+p,m=new h.onnx.TypeProto;d.pos<_;){var g=d.uint32();switch(g>>>3){case 1:m.tensorType=h.onnx.TypeProto.Tensor.decode(d,d.uint32());break;case 4:m.sequenceType=h.onnx.TypeProto.Sequence.decode(d,d.uint32());break;case 5:m.mapType=h.onnx.TypeProto.Map.decode(d,d.uint32());break;case 9:m.optionalType=h.onnx.TypeProto.Optional.decode(d,d.uint32());break;case 8:m.sparseTensorType=h.onnx.TypeProto.SparseTensor.decode(d,d.uint32());break;case 6:m.denotation=d.string();break;default:d.skipType(7&g)}}return m},u.decodeDelimited=function(d){return d instanceof l||(d=new l(d)),this.decode(d,d.uint32())},u.verify=function(d){if(typeof d!="object"||d===null)return"object expected";var p={};if(d.tensorType!=null&&d.hasOwnProperty("tensorType")&&(p.value=1,_=h.onnx.TypeProto.Tensor.verify(d.tensorType)))return"tensorType."+_;if(d.sequenceType!=null&&d.hasOwnProperty("sequenceType")){if(p.value===1)return"value: multiple values";if(p.value=1,_=h.onnx.TypeProto.Sequence.verify(d.sequenceType))return"sequenceType."+_}if(d.mapType!=null&&d.hasOwnProperty("mapType")){if(p.value===1)return"value: multiple values";if(p.value=1,_=h.onnx.TypeProto.Map.verify(d.mapType))return"mapType."+_}if(d.optionalType!=null&&d.hasOwnProperty("optionalType")){if(p.value===1)return"value: multiple values";if(p.value=1,_=h.onnx.TypeProto.Optional.verify(d.optionalType))return"optionalType."+_}if(d.sparseTensorType!=null&&d.hasOwnProperty("sparseTensorType")){if(p.value===1)return"value: multiple values";var _;if(p.value=1,_=h.onnx.TypeProto.SparseTensor.verify(d.sparseTensorType))return"sparseTensorType."+_}return d.denotation!=null&&d.hasOwnProperty("denotation")&&!f.isString(d.denotation)?"denotation: string expected":null},u.fromObject=function(d){if(d instanceof h.onnx.TypeProto)return d;var p=new h.onnx.TypeProto;if(d.tensorType!=null){if(typeof d.tensorType!="object")throw TypeError(".onnx.TypeProto.tensorType: object expected");p.tensorType=h.onnx.TypeProto.Tensor.fromObject(d.tensorType)}if(d.sequenceType!=null){if(typeof d.sequenceType!="object")throw TypeError(".onnx.TypeProto.sequenceType: object expected");p.sequenceType=h.onnx.TypeProto.Sequence.fromObject(d.sequenceType)}if(d.mapType!=null){if(typeof d.mapType!="object")throw TypeError(".onnx.TypeProto.mapType: object expected");p.mapType=h.onnx.TypeProto.Map.fromObject(d.mapType)}if(d.optionalType!=null){if(typeof d.optionalType!="object")throw TypeError(".onnx.TypeProto.optionalType: object expected");p.optionalType=h.onnx.TypeProto.Optional.fromObject(d.optionalType)}if(d.sparseTensorType!=null){if(typeof d.sparseTensorType!="object")throw TypeError(".onnx.TypeProto.sparseTensorType: object expected");p.sparseTensorType=h.onnx.TypeProto.SparseTensor.fromObject(d.sparseTensorType)}return d.denotation!=null&&(p.denotation=String(d.denotation)),p},u.toObject=function(d,p){p||(p={});var _={};return p.defaults&&(_.denotation=""),d.tensorType!=null&&d.hasOwnProperty("tensorType")&&(_.tensorType=h.onnx.TypeProto.Tensor.toObject(d.tensorType,p),p.oneofs&&(_.value="tensorType")),d.sequenceType!=null&&d.hasOwnProperty("sequenceType")&&(_.sequenceType=h.onnx.TypeProto.Sequence.toObject(d.sequenceType,p),p.oneofs&&(_.value="sequenceType")),d.mapType!=null&&d.hasOwnProperty("mapType")&&(_.mapType=h.onnx.TypeProto.Map.toObject(d.mapType,p),p.oneofs&&(_.value="mapType")),d.denotation!=null&&d.hasOwnProperty("denotation")&&(_.denotation=d.denotation),d.sparseTensorType!=null&&d.hasOwnProperty("sparseTensorType")&&(_.sparseTensorType=h.onnx.TypeProto.SparseTensor.toObject(d.sparseTensorType,p),p.oneofs&&(_.value="sparseTensorType")),d.optionalType!=null&&d.hasOwnProperty("optionalType")&&(_.optionalType=h.onnx.TypeProto.Optional.toObject(d.optionalType,p),p.oneofs&&(_.value="optionalType")),_},u.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},u.getTypeUrl=function(d){return d===void 0&&(d="type.googleapis.com"),d+"/onnx.TypeProto"},u.Tensor=function(){function d(p){if(p)for(var _=Object.keys(p),m=0;m<_.length;++m)p[_[m]]!=null&&(this[_[m]]=p[_[m]])}return d.prototype.elemType=0,d.prototype.shape=null,d.create=function(p){return new d(p)},d.encode=function(p,_){return _||(_=c.create()),p.elemType!=null&&Object.hasOwnProperty.call(p,"elemType")&&_.uint32(8).int32(p.elemType),p.shape!=null&&Object.hasOwnProperty.call(p,"shape")&&h.onnx.TensorShapeProto.encode(p.shape,_.uint32(18).fork()).ldelim(),_},d.encodeDelimited=function(p,_){return this.encode(p,_).ldelim()},d.decode=function(p,_){p instanceof l||(p=l.create(p));for(var m=_===void 0?p.len:p.pos+_,g=new h.onnx.TypeProto.Tensor;p.pos<m;){var b=p.uint32();switch(b>>>3){case 1:g.elemType=p.int32();break;case 2:g.shape=h.onnx.TensorShapeProto.decode(p,p.uint32());break;default:p.skipType(7&b)}}return g},d.decodeDelimited=function(p){return p instanceof l||(p=new l(p)),this.decode(p,p.uint32())},d.verify=function(p){if(typeof p!="object"||p===null)return"object expected";if(p.elemType!=null&&p.hasOwnProperty("elemType")&&!f.isInteger(p.elemType))return"elemType: integer expected";if(p.shape!=null&&p.hasOwnProperty("shape")){var _=h.onnx.TensorShapeProto.verify(p.shape);if(_)return"shape."+_}return null},d.fromObject=function(p){if(p instanceof h.onnx.TypeProto.Tensor)return p;var _=new h.onnx.TypeProto.Tensor;if(p.elemType!=null&&(_.elemType=0|p.elemType),p.shape!=null){if(typeof p.shape!="object")throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");_.shape=h.onnx.TensorShapeProto.fromObject(p.shape)}return _},d.toObject=function(p,_){_||(_={});var m={};return _.defaults&&(m.elemType=0,m.shape=null),p.elemType!=null&&p.hasOwnProperty("elemType")&&(m.elemType=p.elemType),p.shape!=null&&p.hasOwnProperty("shape")&&(m.shape=h.onnx.TensorShapeProto.toObject(p.shape,_)),m},d.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},d.getTypeUrl=function(p){return p===void 0&&(p="type.googleapis.com"),p+"/onnx.TypeProto.Tensor"},d}(),u.Sequence=function(){function d(p){if(p)for(var _=Object.keys(p),m=0;m<_.length;++m)p[_[m]]!=null&&(this[_[m]]=p[_[m]])}return d.prototype.elemType=null,d.create=function(p){return new d(p)},d.encode=function(p,_){return _||(_=c.create()),p.elemType!=null&&Object.hasOwnProperty.call(p,"elemType")&&h.onnx.TypeProto.encode(p.elemType,_.uint32(10).fork()).ldelim(),_},d.encodeDelimited=function(p,_){return this.encode(p,_).ldelim()},d.decode=function(p,_){p instanceof l||(p=l.create(p));for(var m=_===void 0?p.len:p.pos+_,g=new h.onnx.TypeProto.Sequence;p.pos<m;){var b=p.uint32();b>>>3==1?g.elemType=h.onnx.TypeProto.decode(p,p.uint32()):p.skipType(7&b)}return g},d.decodeDelimited=function(p){return p instanceof l||(p=new l(p)),this.decode(p,p.uint32())},d.verify=function(p){if(typeof p!="object"||p===null)return"object expected";if(p.elemType!=null&&p.hasOwnProperty("elemType")){var _=h.onnx.TypeProto.verify(p.elemType);if(_)return"elemType."+_}return null},d.fromObject=function(p){if(p instanceof h.onnx.TypeProto.Sequence)return p;var _=new h.onnx.TypeProto.Sequence;if(p.elemType!=null){if(typeof p.elemType!="object")throw TypeError(".onnx.TypeProto.Sequence.elemType: object expected");_.elemType=h.onnx.TypeProto.fromObject(p.elemType)}return _},d.toObject=function(p,_){_||(_={});var m={};return _.defaults&&(m.elemType=null),p.elemType!=null&&p.hasOwnProperty("elemType")&&(m.elemType=h.onnx.TypeProto.toObject(p.elemType,_)),m},d.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},d.getTypeUrl=function(p){return p===void 0&&(p="type.googleapis.com"),p+"/onnx.TypeProto.Sequence"},d}(),u.Map=function(){function d(p){if(p)for(var _=Object.keys(p),m=0;m<_.length;++m)p[_[m]]!=null&&(this[_[m]]=p[_[m]])}return d.prototype.keyType=0,d.prototype.valueType=null,d.create=function(p){return new d(p)},d.encode=function(p,_){return _||(_=c.create()),p.keyType!=null&&Object.hasOwnProperty.call(p,"keyType")&&_.uint32(8).int32(p.keyType),p.valueType!=null&&Object.hasOwnProperty.call(p,"valueType")&&h.onnx.TypeProto.encode(p.valueType,_.uint32(18).fork()).ldelim(),_},d.encodeDelimited=function(p,_){return this.encode(p,_).ldelim()},d.decode=function(p,_){p instanceof l||(p=l.create(p));for(var m=_===void 0?p.len:p.pos+_,g=new h.onnx.TypeProto.Map;p.pos<m;){var b=p.uint32();switch(b>>>3){case 1:g.keyType=p.int32();break;case 2:g.valueType=h.onnx.TypeProto.decode(p,p.uint32());break;default:p.skipType(7&b)}}return g},d.decodeDelimited=function(p){return p instanceof l||(p=new l(p)),this.decode(p,p.uint32())},d.verify=function(p){if(typeof p!="object"||p===null)return"object expected";if(p.keyType!=null&&p.hasOwnProperty("keyType")&&!f.isInteger(p.keyType))return"keyType: integer expected";if(p.valueType!=null&&p.hasOwnProperty("valueType")){var _=h.onnx.TypeProto.verify(p.valueType);if(_)return"valueType."+_}return null},d.fromObject=function(p){if(p instanceof h.onnx.TypeProto.Map)return p;var _=new h.onnx.TypeProto.Map;if(p.keyType!=null&&(_.keyType=0|p.keyType),p.valueType!=null){if(typeof p.valueType!="object")throw TypeError(".onnx.TypeProto.Map.valueType: object expected");_.valueType=h.onnx.TypeProto.fromObject(p.valueType)}return _},d.toObject=function(p,_){_||(_={});var m={};return _.defaults&&(m.keyType=0,m.valueType=null),p.keyType!=null&&p.hasOwnProperty("keyType")&&(m.keyType=p.keyType),p.valueType!=null&&p.hasOwnProperty("valueType")&&(m.valueType=h.onnx.TypeProto.toObject(p.valueType,_)),m},d.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},d.getTypeUrl=function(p){return p===void 0&&(p="type.googleapis.com"),p+"/onnx.TypeProto.Map"},d}(),u.Optional=function(){function d(p){if(p)for(var _=Object.keys(p),m=0;m<_.length;++m)p[_[m]]!=null&&(this[_[m]]=p[_[m]])}return d.prototype.elemType=null,d.create=function(p){return new d(p)},d.encode=function(p,_){return _||(_=c.create()),p.elemType!=null&&Object.hasOwnProperty.call(p,"elemType")&&h.onnx.TypeProto.encode(p.elemType,_.uint32(10).fork()).ldelim(),_},d.encodeDelimited=function(p,_){return this.encode(p,_).ldelim()},d.decode=function(p,_){p instanceof l||(p=l.create(p));for(var m=_===void 0?p.len:p.pos+_,g=new h.onnx.TypeProto.Optional;p.pos<m;){var b=p.uint32();b>>>3==1?g.elemType=h.onnx.TypeProto.decode(p,p.uint32()):p.skipType(7&b)}return g},d.decodeDelimited=function(p){return p instanceof l||(p=new l(p)),this.decode(p,p.uint32())},d.verify=function(p){if(typeof p!="object"||p===null)return"object expected";if(p.elemType!=null&&p.hasOwnProperty("elemType")){var _=h.onnx.TypeProto.verify(p.elemType);if(_)return"elemType."+_}return null},d.fromObject=function(p){if(p instanceof h.onnx.TypeProto.Optional)return p;var _=new h.onnx.TypeProto.Optional;if(p.elemType!=null){if(typeof p.elemType!="object")throw TypeError(".onnx.TypeProto.Optional.elemType: object expected");_.elemType=h.onnx.TypeProto.fromObject(p.elemType)}return _},d.toObject=function(p,_){_||(_={});var m={};return _.defaults&&(m.elemType=null),p.elemType!=null&&p.hasOwnProperty("elemType")&&(m.elemType=h.onnx.TypeProto.toObject(p.elemType,_)),m},d.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},d.getTypeUrl=function(p){return p===void 0&&(p="type.googleapis.com"),p+"/onnx.TypeProto.Optional"},d}(),u.SparseTensor=function(){function d(p){if(p)for(var _=Object.keys(p),m=0;m<_.length;++m)p[_[m]]!=null&&(this[_[m]]=p[_[m]])}return d.prototype.elemType=0,d.prototype.shape=null,d.create=function(p){return new d(p)},d.encode=function(p,_){return _||(_=c.create()),p.elemType!=null&&Object.hasOwnProperty.call(p,"elemType")&&_.uint32(8).int32(p.elemType),p.shape!=null&&Object.hasOwnProperty.call(p,"shape")&&h.onnx.TensorShapeProto.encode(p.shape,_.uint32(18).fork()).ldelim(),_},d.encodeDelimited=function(p,_){return this.encode(p,_).ldelim()},d.decode=function(p,_){p instanceof l||(p=l.create(p));for(var m=_===void 0?p.len:p.pos+_,g=new h.onnx.TypeProto.SparseTensor;p.pos<m;){var b=p.uint32();switch(b>>>3){case 1:g.elemType=p.int32();break;case 2:g.shape=h.onnx.TensorShapeProto.decode(p,p.uint32());break;default:p.skipType(7&b)}}return g},d.decodeDelimited=function(p){return p instanceof l||(p=new l(p)),this.decode(p,p.uint32())},d.verify=function(p){if(typeof p!="object"||p===null)return"object expected";if(p.elemType!=null&&p.hasOwnProperty("elemType")&&!f.isInteger(p.elemType))return"elemType: integer expected";if(p.shape!=null&&p.hasOwnProperty("shape")){var _=h.onnx.TensorShapeProto.verify(p.shape);if(_)return"shape."+_}return null},d.fromObject=function(p){if(p instanceof h.onnx.TypeProto.SparseTensor)return p;var _=new h.onnx.TypeProto.SparseTensor;if(p.elemType!=null&&(_.elemType=0|p.elemType),p.shape!=null){if(typeof p.shape!="object")throw TypeError(".onnx.TypeProto.SparseTensor.shape: object expected");_.shape=h.onnx.TensorShapeProto.fromObject(p.shape)}return _},d.toObject=function(p,_){_||(_={});var m={};return _.defaults&&(m.elemType=0,m.shape=null),p.elemType!=null&&p.hasOwnProperty("elemType")&&(m.elemType=p.elemType),p.shape!=null&&p.hasOwnProperty("shape")&&(m.shape=h.onnx.TensorShapeProto.toObject(p.shape,_)),m},d.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},d.getTypeUrl=function(p){return p===void 0&&(p="type.googleapis.com"),p+"/onnx.TypeProto.SparseTensor"},d}(),u}(),o.OperatorSetIdProto=function(){function u(i){if(i)for(var d=Object.keys(i),p=0;p<d.length;++p)i[d[p]]!=null&&(this[d[p]]=i[d[p]])}return u.prototype.domain="",u.prototype.version=f.Long?f.Long.fromBits(0,0,!1):0,u.create=function(i){return new u(i)},u.encode=function(i,d){return d||(d=c.create()),i.domain!=null&&Object.hasOwnProperty.call(i,"domain")&&d.uint32(10).string(i.domain),i.version!=null&&Object.hasOwnProperty.call(i,"version")&&d.uint32(16).int64(i.version),d},u.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},u.decode=function(i,d){i instanceof l||(i=l.create(i));for(var p=d===void 0?i.len:i.pos+d,_=new h.onnx.OperatorSetIdProto;i.pos<p;){var m=i.uint32();switch(m>>>3){case 1:_.domain=i.string();break;case 2:_.version=i.int64();break;default:i.skipType(7&m)}}return _},u.decodeDelimited=function(i){return i instanceof l||(i=new l(i)),this.decode(i,i.uint32())},u.verify=function(i){return typeof i!="object"||i===null?"object expected":i.domain!=null&&i.hasOwnProperty("domain")&&!f.isString(i.domain)?"domain: string expected":i.version!=null&&i.hasOwnProperty("version")&&!(f.isInteger(i.version)||i.version&&f.isInteger(i.version.low)&&f.isInteger(i.version.high))?"version: integer|Long expected":null},u.fromObject=function(i){if(i instanceof h.onnx.OperatorSetIdProto)return i;var d=new h.onnx.OperatorSetIdProto;return i.domain!=null&&(d.domain=String(i.domain)),i.version!=null&&(f.Long?(d.version=f.Long.fromValue(i.version)).unsigned=!1:typeof i.version=="string"?d.version=parseInt(i.version,10):typeof i.version=="number"?d.version=i.version:typeof i.version=="object"&&(d.version=new f.LongBits(i.version.low>>>0,i.version.high>>>0).toNumber())),d},u.toObject=function(i,d){d||(d={});var p={};if(d.defaults)if(p.domain="",f.Long){var _=new f.Long(0,0,!1);p.version=d.longs===String?_.toString():d.longs===Number?_.toNumber():_}else p.version=d.longs===String?"0":0;return i.domain!=null&&i.hasOwnProperty("domain")&&(p.domain=i.domain),i.version!=null&&i.hasOwnProperty("version")&&(typeof i.version=="number"?p.version=d.longs===String?String(i.version):i.version:p.version=d.longs===String?f.Long.prototype.toString.call(i.version):d.longs===Number?new f.LongBits(i.version.low>>>0,i.version.high>>>0).toNumber():i.version),p},u.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},u.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.OperatorSetIdProto"},u}(),o.OperatorStatus=function(){var u={},i=Object.create(u);return i[u[0]="EXPERIMENTAL"]=0,i[u[1]="STABLE"]=1,i}(),o.FunctionProto=function(){function u(i){if(this.input=[],this.output=[],this.attribute=[],this.attributeProto=[],this.node=[],this.opsetImport=[],i)for(var d=Object.keys(i),p=0;p<d.length;++p)i[d[p]]!=null&&(this[d[p]]=i[d[p]])}return u.prototype.name="",u.prototype.input=f.emptyArray,u.prototype.output=f.emptyArray,u.prototype.attribute=f.emptyArray,u.prototype.attributeProto=f.emptyArray,u.prototype.node=f.emptyArray,u.prototype.docString="",u.prototype.opsetImport=f.emptyArray,u.prototype.domain="",u.create=function(i){return new u(i)},u.encode=function(i,d){if(d||(d=c.create()),i.name!=null&&Object.hasOwnProperty.call(i,"name")&&d.uint32(10).string(i.name),i.input!=null&&i.input.length)for(var p=0;p<i.input.length;++p)d.uint32(34).string(i.input[p]);if(i.output!=null&&i.output.length)for(p=0;p<i.output.length;++p)d.uint32(42).string(i.output[p]);if(i.attribute!=null&&i.attribute.length)for(p=0;p<i.attribute.length;++p)d.uint32(50).string(i.attribute[p]);if(i.node!=null&&i.node.length)for(p=0;p<i.node.length;++p)h.onnx.NodeProto.encode(i.node[p],d.uint32(58).fork()).ldelim();if(i.docString!=null&&Object.hasOwnProperty.call(i,"docString")&&d.uint32(66).string(i.docString),i.opsetImport!=null&&i.opsetImport.length)for(p=0;p<i.opsetImport.length;++p)h.onnx.OperatorSetIdProto.encode(i.opsetImport[p],d.uint32(74).fork()).ldelim();if(i.domain!=null&&Object.hasOwnProperty.call(i,"domain")&&d.uint32(82).string(i.domain),i.attributeProto!=null&&i.attributeProto.length)for(p=0;p<i.attributeProto.length;++p)h.onnx.AttributeProto.encode(i.attributeProto[p],d.uint32(90).fork()).ldelim();return d},u.encodeDelimited=function(i,d){return this.encode(i,d).ldelim()},u.decode=function(i,d){i instanceof l||(i=l.create(i));for(var p=d===void 0?i.len:i.pos+d,_=new h.onnx.FunctionProto;i.pos<p;){var m=i.uint32();switch(m>>>3){case 1:_.name=i.string();break;case 4:_.input&&_.input.length||(_.input=[]),_.input.push(i.string());break;case 5:_.output&&_.output.length||(_.output=[]),_.output.push(i.string());break;case 6:_.attribute&&_.attribute.length||(_.attribute=[]),_.attribute.push(i.string());break;case 11:_.attributeProto&&_.attributeProto.length||(_.attributeProto=[]),_.attributeProto.push(h.onnx.AttributeProto.decode(i,i.uint32()));break;case 7:_.node&&_.node.length||(_.node=[]),_.node.push(h.onnx.NodeProto.decode(i,i.uint32()));break;case 8:_.docString=i.string();break;case 9:_.opsetImport&&_.opsetImport.length||(_.opsetImport=[]),_.opsetImport.push(h.onnx.OperatorSetIdProto.decode(i,i.uint32()));break;case 10:_.domain=i.string();break;default:i.skipType(7&m)}}return _},u.decodeDelimited=function(i){return i instanceof l||(i=new l(i)),this.decode(i,i.uint32())},u.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.name!=null&&i.hasOwnProperty("name")&&!f.isString(i.name))return"name: string expected";if(i.input!=null&&i.hasOwnProperty("input")){if(!Array.isArray(i.input))return"input: array expected";for(var d=0;d<i.input.length;++d)if(!f.isString(i.input[d]))return"input: string[] expected"}if(i.output!=null&&i.hasOwnProperty("output")){if(!Array.isArray(i.output))return"output: array expected";for(d=0;d<i.output.length;++d)if(!f.isString(i.output[d]))return"output: string[] expected"}if(i.attribute!=null&&i.hasOwnProperty("attribute")){if(!Array.isArray(i.attribute))return"attribute: array expected";for(d=0;d<i.attribute.length;++d)if(!f.isString(i.attribute[d]))return"attribute: string[] expected"}if(i.attributeProto!=null&&i.hasOwnProperty("attributeProto")){if(!Array.isArray(i.attributeProto))return"attributeProto: array expected";for(d=0;d<i.attributeProto.length;++d)if(p=h.onnx.AttributeProto.verify(i.attributeProto[d]))return"attributeProto."+p}if(i.node!=null&&i.hasOwnProperty("node")){if(!Array.isArray(i.node))return"node: array expected";for(d=0;d<i.node.length;++d)if(p=h.onnx.NodeProto.verify(i.node[d]))return"node."+p}if(i.docString!=null&&i.hasOwnProperty("docString")&&!f.isString(i.docString))return"docString: string expected";if(i.opsetImport!=null&&i.hasOwnProperty("opsetImport")){if(!Array.isArray(i.opsetImport))return"opsetImport: array expected";for(d=0;d<i.opsetImport.length;++d){var p;if(p=h.onnx.OperatorSetIdProto.verify(i.opsetImport[d]))return"opsetImport."+p}}return i.domain!=null&&i.hasOwnProperty("domain")&&!f.isString(i.domain)?"domain: string expected":null},u.fromObject=function(i){if(i instanceof h.onnx.FunctionProto)return i;var d=new h.onnx.FunctionProto;if(i.name!=null&&(d.name=String(i.name)),i.input){if(!Array.isArray(i.input))throw TypeError(".onnx.FunctionProto.input: array expected");d.input=[];for(var p=0;p<i.input.length;++p)d.input[p]=String(i.input[p])}if(i.output){if(!Array.isArray(i.output))throw TypeError(".onnx.FunctionProto.output: array expected");for(d.output=[],p=0;p<i.output.length;++p)d.output[p]=String(i.output[p])}if(i.attribute){if(!Array.isArray(i.attribute))throw TypeError(".onnx.FunctionProto.attribute: array expected");for(d.attribute=[],p=0;p<i.attribute.length;++p)d.attribute[p]=String(i.attribute[p])}if(i.attributeProto){if(!Array.isArray(i.attributeProto))throw TypeError(".onnx.FunctionProto.attributeProto: array expected");for(d.attributeProto=[],p=0;p<i.attributeProto.length;++p){if(typeof i.attributeProto[p]!="object")throw TypeError(".onnx.FunctionProto.attributeProto: object expected");d.attributeProto[p]=h.onnx.AttributeProto.fromObject(i.attributeProto[p])}}if(i.node){if(!Array.isArray(i.node))throw TypeError(".onnx.FunctionProto.node: array expected");for(d.node=[],p=0;p<i.node.length;++p){if(typeof i.node[p]!="object")throw TypeError(".onnx.FunctionProto.node: object expected");d.node[p]=h.onnx.NodeProto.fromObject(i.node[p])}}if(i.docString!=null&&(d.docString=String(i.docString)),i.opsetImport){if(!Array.isArray(i.opsetImport))throw TypeError(".onnx.FunctionProto.opsetImport: array expected");for(d.opsetImport=[],p=0;p<i.opsetImport.length;++p){if(typeof i.opsetImport[p]!="object")throw TypeError(".onnx.FunctionProto.opsetImport: object expected");d.opsetImport[p]=h.onnx.OperatorSetIdProto.fromObject(i.opsetImport[p])}}return i.domain!=null&&(d.domain=String(i.domain)),d},u.toObject=function(i,d){d||(d={});var p={};if((d.arrays||d.defaults)&&(p.input=[],p.output=[],p.attribute=[],p.node=[],p.opsetImport=[],p.attributeProto=[]),d.defaults&&(p.name="",p.docString="",p.domain=""),i.name!=null&&i.hasOwnProperty("name")&&(p.name=i.name),i.input&&i.input.length){p.input=[];for(var _=0;_<i.input.length;++_)p.input[_]=i.input[_]}if(i.output&&i.output.length)for(p.output=[],_=0;_<i.output.length;++_)p.output[_]=i.output[_];if(i.attribute&&i.attribute.length)for(p.attribute=[],_=0;_<i.attribute.length;++_)p.attribute[_]=i.attribute[_];if(i.node&&i.node.length)for(p.node=[],_=0;_<i.node.length;++_)p.node[_]=h.onnx.NodeProto.toObject(i.node[_],d);if(i.docString!=null&&i.hasOwnProperty("docString")&&(p.docString=i.docString),i.opsetImport&&i.opsetImport.length)for(p.opsetImport=[],_=0;_<i.opsetImport.length;++_)p.opsetImport[_]=h.onnx.OperatorSetIdProto.toObject(i.opsetImport[_],d);if(i.domain!=null&&i.hasOwnProperty("domain")&&(p.domain=i.domain),i.attributeProto&&i.attributeProto.length)for(p.attributeProto=[],_=0;_<i.attributeProto.length;++_)p.attributeProto[_]=h.onnx.AttributeProto.toObject(i.attributeProto[_],d);return p},u.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},u.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/onnx.FunctionProto"},u}(),o),a.exports=h},3474:(a,e,n)=>{var t,r=(t=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0,typeof __filename<"u"&&(t=t||__filename),function(o={}){function s(){return K.buffer!=te.buffer&&ge(),te}function l(){return K.buffer!=te.buffer&&ge(),ee}function c(){return K.buffer!=te.buffer&&ge(),ie}function f(){return K.buffer!=te.buffer&&ge(),ae}function h(){return K.buffer!=te.buffer&&ge(),ue}var u,i,d=o;d.ready=new Promise((x,N)=>{u=x,i=N});var p,_,m,g=Object.assign({},d),b="./this.program",v=(x,N)=>{throw N},T=typeof window=="object",y=typeof importScripts=="function",w=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",S=d.ENVIRONMENT_IS_PTHREAD||!1,O="";function P(x){return d.locateFile?d.locateFile(x,O):O+x}if(w){var E=n(1384),A=n(908);let x;O=y?A.dirname(O)+"/":__dirname+"/",p=(N,M)=>(N=N.startsWith("file://")?new URL(N):A.normalize(N),E.readFileSync(N,M?void 0:"utf8")),m=N=>((N=p(N,!0)).buffer||(N=new Uint8Array(N)),N),_=(N,M,V,Z=!0)=>{N=N.startsWith("file://")?new URL(N):A.normalize(N),E.readFile(N,Z?void 0:"utf8",(ne,se)=>{ne?V(ne):M(Z?se.buffer:se)})},!d.thisProgram&&1<process.argv.length&&(b=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),v=(N,M)=>{throw process.exitCode=N,M},d.inspect=()=>"[Emscripten Module object]";try{x=n(9925)}catch(N){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),N}commonjsGlobal.Worker=x.Worker}else(T||y)&&(y?O=self.location.href:typeof document<"u"&&document.currentScript&&(O=document.currentScript.src),t&&(O=t),O=O.indexOf("blob:")!==0?O.substr(0,O.replace(/[?#].*/,"").lastIndexOf("/")+1):"",w||(p=x=>{var N=new XMLHttpRequest;return N.open("GET",x,!1),N.send(null),N.responseText},y&&(m=x=>{var N=new XMLHttpRequest;return N.open("GET",x,!1),N.responseType="arraybuffer",N.send(null),new Uint8Array(N.response)}),_=(x,N,M)=>{var V=new XMLHttpRequest;V.open("GET",x,!0),V.responseType="arraybuffer",V.onload=()=>{V.status==200||V.status==0&&V.response?N(V.response):M()},V.onerror=M,V.send(null)}));w&&typeof performance>"u"&&(commonjsGlobal.performance=n(6953).performance);var $=console.log.bind(console),k=console.error.bind(console);w&&($=(...x)=>E.writeSync(1,x.join(" ")+`
`),k=(...x)=>E.writeSync(2,x.join(" ")+`
`));var D,I=d.print||$,C=d.printErr||k;Object.assign(d,g),g=null,d.thisProgram&&(b=d.thisProgram),d.quit&&(v=d.quit),d.wasmBinary&&(D=d.wasmBinary);var L=d.noExitRuntime||!0;typeof WebAssembly!="object"&&Oe("no native wasm support detected");var K,G,J,Y,te,ee,ie,ae,ue,fe=!1;function ge(){var x=K.buffer;d.HEAP8=te=new Int8Array(x),d.HEAP16=new Int16Array(x),d.HEAP32=ie=new Int32Array(x),d.HEAPU8=ee=new Uint8Array(x),d.HEAPU16=new Uint16Array(x),d.HEAPU32=ae=new Uint32Array(x),d.HEAPF32=new Float32Array(x),d.HEAPF64=ue=new Float64Array(x)}var be=d.INITIAL_MEMORY||16777216;if(5242880<=be||Oe("INITIAL_MEMORY should be larger than STACK_SIZE, was "+be+"! (STACK_SIZE=5242880)"),S)K=d.wasmMemory;else if(d.wasmMemory)K=d.wasmMemory;else if(!((K=new WebAssembly.Memory({initial:be/65536,maximum:65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw C("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),w&&C("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");ge(),be=K.buffer.byteLength;var xe,ve=[],Te=[],pe=[],ke=0;function Pe(){return L||0<ke}var Ie,Ce,Ne=0,Ae=null;function Ve(){Ne++,d.monitorRunDependencies&&d.monitorRunDependencies(Ne)}function $e(){if(Ne--,d.monitorRunDependencies&&d.monitorRunDependencies(Ne),Ne==0&&Ae){var x=Ae;Ae=null,x()}}function Oe(x){throw d.onAbort&&d.onAbort(x),C(x="Aborted("+x+")"),fe=!0,Y=1,x=new WebAssembly.RuntimeError(x+". Build with -sASSERTIONS for more info."),i(x),x}function Fe(x){return x.startsWith("data:application/octet-stream;base64,")}function We(x){if(x==Ie&&D)return new Uint8Array(D);if(m)return m(x);throw"both async and sync fetching of the wasm failed"}function Qe(x,N,M){return function(V){if(!D&&(T||y)){if(typeof fetch=="function"&&!V.startsWith("file://"))return fetch(V,{credentials:"same-origin"}).then(Z=>{if(!Z.ok)throw"failed to load wasm binary file at '"+V+"'";return Z.arrayBuffer()}).catch(()=>We(V));if(_)return new Promise((Z,ne)=>{_(V,se=>Z(new Uint8Array(se)),ne)})}return Promise.resolve().then(()=>We(V))}(x).then(V=>WebAssembly.instantiate(V,N)).then(V=>V).then(M,V=>{C("failed to asynchronously prepare wasm: "+V),Oe(V)})}function je(x){this.name="ExitStatus",this.message=`Program terminated with exit(${x})`,this.status=x}function Be(x){x.terminate(),x.onmessage=()=>{}}function ze(x){(x=le.Fa[x])||Oe(),le.fb(x)}function He(x){var N=le.Za();if(!N)return 6;le.Ia.push(N),le.Fa[x.Ha]=N,N.Ha=x.Ha;var M={cmd:"run",start_routine:x.gb,arg:x.Ya,pthread_ptr:x.Ha};return w&&N.unref(),N.postMessage(M,x.mb),0}Fe(Ie="ort-wasm-threaded.wasm")||(Ie=P(Ie));var et=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,qe=(x,N,M)=>{var V=(N>>>=0)+M;for(M=N;x[M]&&!(M>=V);)++M;if(16<M-N&&x.buffer&&et)return et.decode(x.buffer instanceof SharedArrayBuffer?x.slice(N,M):x.subarray(N,M));for(V="";N<M;){var Z=x[N++];if(128&Z){var ne=63&x[N++];if((224&Z)==192)V+=String.fromCharCode((31&Z)<<6|ne);else{var se=63&x[N++];65536>(Z=(240&Z)==224?(15&Z)<<12|ne<<6|se:(7&Z)<<18|ne<<12|se<<6|63&x[N++])?V+=String.fromCharCode(Z):(Z-=65536,V+=String.fromCharCode(55296|Z>>10,56320|1023&Z))}}else V+=String.fromCharCode(Z)}return V},Ue=(x,N)=>(x>>>=0)?qe(l(),x,N):"";function Ke(x){if(S)return ye(1,1,x);Y=x,Pe()||(le.hb(),d.onExit&&d.onExit(x),fe=!0),v(x,new je(x))}var Ze=x=>{if(Y=x,S)throw Ye(x),"unwind";Ke(x)},le={La:[],Ia:[],Ta:[],Fa:{},Pa:function(){S?le.ab():le.$a()},$a:function(){ve.unshift(()=>{Ve(),le.bb(()=>$e())})},ab:function(){le.receiveObjectTransfer=le.eb,le.threadInitTLS=le.Sa,le.setExitStatus=le.Ra,L=!1},Ra:function(x){Y=x},rb:["$terminateWorker"],hb:function(){for(var x of le.Ia)Be(x);for(x of le.La)Be(x);le.La=[],le.Ia=[],le.Fa=[]},fb:function(x){var N=x.Ha;delete le.Fa[N],le.La.push(x),le.Ia.splice(le.Ia.indexOf(x),1),x.Ha=0,dt(N)},eb:function(){},Sa:function(){le.Ta.forEach(x=>x())},cb:x=>new Promise(N=>{x.onmessage=Z=>{var ne=(Z=Z.data).cmd;if(Z.targetThread&&Z.targetThread!=it()){var se=le.Fa[Z.qb];se?se.postMessage(Z,Z.transferList):C('Internal error! Worker sent a message "'+ne+'" to target pthread '+Z.targetThread+", but that thread no longer exists!")}else ne==="checkMailbox"?rt():ne==="spawnThread"?He(Z):ne==="cleanupThread"?ze(Z.thread):ne==="killThread"?(Z=Z.thread,ne=le.Fa[Z],delete le.Fa[Z],Be(ne),dt(Z),le.Ia.splice(le.Ia.indexOf(ne),1),ne.Ha=0):ne==="cancelThread"?le.Fa[Z.thread].postMessage({cmd:"cancel"}):ne==="loaded"?(x.loaded=!0,N(x)):ne==="alert"?alert("Thread "+Z.threadId+": "+Z.text):Z.target==="setimmediate"?x.postMessage(Z):ne==="callHandler"?d[Z.handler](...Z.args):ne&&C("worker sent an unknown command "+ne)},x.onerror=Z=>{throw C("worker sent an error! "+Z.filename+":"+Z.lineno+": "+Z.message),Z},w&&(x.on("message",function(Z){x.onmessage({data:Z})}),x.on("error",function(Z){x.onerror(Z)}));var M,V=[];for(M of["onExit","onAbort","print","printErr"])d.hasOwnProperty(M)&&V.push(M);x.postMessage({cmd:"load",handlers:V,urlOrBlob:d.mainScriptUrlOrBlob||t,wasmMemory:K,wasmModule:J})}),bb:function(x){x()},Xa:function(){var x=P("ort-wasm-threaded.worker.js");x=new Worker(x),le.La.push(x)},Za:function(){return le.La.length==0&&(le.Xa(),le.cb(le.La[0])),le.La.pop()}};d.PThread=le;var Ge=x=>{for(;0<x.length;)x.shift()(d)};function Ye(x){if(S)return ye(2,0,x);Ze(x)}d.establishStackSpace=function(){var x=it(),N=c()[x+52>>2>>>0];x=c()[x+56>>2>>>0],Mt(N,N-x),at(N)};var R=[];function j(x){this.Oa=x-24,this.Wa=function(N){f()[this.Oa+4>>2>>>0]=N},this.Va=function(N){f()[this.Oa+8>>2>>>0]=N},this.Pa=function(N,M){this.Ua(),this.Wa(N),this.Va(M)},this.Ua=function(){f()[this.Oa+16>>2>>>0]=0}}function B(x,N,M,V){return S?ye(3,1,x,N,M,V):q(x,N,M,V)}function q(x,N,M,V){if(x>>>=0,N>>>=0,M>>>=0,V>>>=0,typeof SharedArrayBuffer>"u")return C("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var Z=[];return S&&Z.length===0?B(x,N,M,V):(x={gb:M,Ha:x,Ya:V,mb:Z},S?(x.ob="spawnThread",postMessage(x,Z),0):He(x))}function Q(x,N,M){return S?ye(4,1,x,N,M):0}function F(x,N){if(S)return ye(5,1,x,N)}d.invokeEntryPoint=function(x,N){var M=R[x];M||(x>=R.length&&(R.length=x+1),R[x]=M=xe.get(x)),x=M(N),Pe()?le.Ra(x):ft(x)};var U=x=>{for(var N=0,M=0;M<x.length;++M){var V=x.charCodeAt(M);127>=V?N++:2047>=V?N+=2:55296<=V&&57343>=V?(N+=4,++M):N+=3}return N},X=(x,N,M,V)=>{if(!(0<V))return 0;var Z=M>>>=0;V=M+V-1;for(var ne=0;ne<x.length;++ne){var se=x.charCodeAt(ne);if(55296<=se&&57343>=se&&(se=65536+((1023&se)<<10)|1023&x.charCodeAt(++ne)),127>=se){if(M>=V)break;N[M++>>>0]=se}else{if(2047>=se){if(M+1>=V)break;N[M++>>>0]=192|se>>6}else{if(65535>=se){if(M+2>=V)break;N[M++>>>0]=224|se>>12}else{if(M+3>=V)break;N[M++>>>0]=240|se>>18,N[M++>>>0]=128|se>>12&63}N[M++>>>0]=128|se>>6&63}N[M++>>>0]=128|63&se}}return N[M>>>0]=0,M-Z},re=(x,N,M)=>X(x,l(),N,M);function oe(x,N){if(S)return ye(6,1,x,N)}function ce(x,N,M){if(S)return ye(7,1,x,N,M)}function he(x,N,M){return S?ye(8,1,x,N,M):0}function De(x,N){if(S)return ye(9,1,x,N)}function H(x,N,M){if(S)return ye(10,1,x,N,M)}function de(x,N,M,V){if(S)return ye(11,1,x,N,M,V)}function me(x,N,M,V){if(S)return ye(12,1,x,N,M,V)}function Le(x,N,M,V){if(S)return ye(13,1,x,N,M,V)}function Xe(x){if(S)return ye(14,1,x)}function _t(x,N){if(S)return ye(15,1,x,N)}function mt(x,N,M){if(S)return ye(16,1,x,N,M)}var zt=x=>{if(!fe)try{if(x(),!Pe())try{S?ft(Y):Ze(Y)}catch(N){N instanceof je||N=="unwind"||v(1,N)}}catch(N){N instanceof je||N=="unwind"||v(1,N)}};function st(x){x>>>=0,typeof Atomics.nb=="function"&&(Atomics.nb(c(),x>>2,x).value.then(rt),x+=128,Atomics.store(c(),x>>2,1))}function rt(){var x=it();x&&(st(x),zt(()=>Ft()))}d.__emscripten_thread_mailbox_await=st,d.checkMailbox=rt;var tt=x=>x%4==0&&(x%100!=0||x%400==0),gt=[0,31,60,91,121,152,182,213,244,274,305,335],bt=[0,31,59,90,120,151,181,212,243,273,304,334];function yt(x,N,M,V,Z,ne,se,we){return S?ye(17,1,x,N,M,V,Z,ne,se,we):-52}function vt(x,N,M,V,Z,ne,se){if(S)return ye(18,1,x,N,M,V,Z,ne,se)}var Tt=x=>{var N=U(x)+1,M=Nt(N);return M&&re(x,M,N),M},Ht=x=>{var N=ht();return x=x(),at(N),x};function ye(x,N){var M=arguments.length-2,V=arguments;return Ht(()=>{for(var Z=pt(8*M),ne=Z>>3,se=0;se<M;se++){var we=V[2+se];h()[ne+se>>>0]=we}return Rt(x,M,Z,N)})}var lt,ct=[],ut={},wt=()=>{if(!lt){var x,N={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:b||"./this.program"};for(x in ut)ut[x]===void 0?delete N[x]:N[x]=ut[x];var M=[];for(x in N)M.push(`${x}=${N[x]}`);lt=M}return lt};function St(x,N){if(S)return ye(19,1,x,N);x>>>=0,N>>>=0;var M=0;return wt().forEach(function(V,Z){var ne=N+M;for(Z=f()[x+4*Z>>2>>>0]=ne,ne=0;ne<V.length;++ne)s()[Z++>>0>>>0]=V.charCodeAt(ne);s()[Z>>0>>>0]=0,M+=V.length+1}),0}function kt(x,N){if(S)return ye(20,1,x,N);x>>>=0,N>>>=0;var M=wt();f()[x>>2>>>0]=M.length;var V=0;return M.forEach(function(Z){V+=Z.length+1}),f()[N>>2>>>0]=V,0}function Ot(x){return S?ye(21,1,x):52}function xt(x,N,M,V){return S?ye(22,1,x,N,M,V):52}function It(x,N,M,V,Z){return S?ye(23,1,x,N,M,V,Z):70}var Zt=[null,[],[]];function Et(x,N,M,V){if(S)return ye(24,1,x,N,M,V);N>>>=0,M>>>=0,V>>>=0;for(var Z=0,ne=0;ne<M;ne++){var se=f()[N>>2>>>0],we=f()[N+4>>2>>>0];N+=8;for(var Me=0;Me<we;Me++){var Ee=l()[se+Me>>>0],Re=Zt[x];Ee===0||Ee===10?((x===1?I:C)(qe(Re,0)),Re.length=0):Re.push(Ee)}Z+=we}return f()[V>>2>>>0]=Z,0}var Pt=x=>(Pt=(()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return V=>(V.set(crypto.getRandomValues(new Uint8Array(V.byteLength))),V);if(w)try{var N=n(760);if(N.randomFillSync)return V=>N.randomFillSync(V);var M=N.randomBytes;return V=>(V.set(M(V.byteLength)),V)}catch{}Oe("initRandomDevice")})())(x),Ct=[31,29,31,30,31,30,31,31,30,31,30,31],At=[31,28,31,30,31,30,31,31,30,31,30,31],Wt=(x,N)=>{s().set(x,N>>>0)};function $t(x,N,M,V){function Z(W,_e,Se){for(W=typeof W=="number"?W.toString():W||"";W.length<_e;)W=Se[0]+W;return W}function ne(W,_e){return Z(W,_e,"0")}function se(W,_e){function Se(Bt){return 0>Bt?-1:0<Bt?1:0}var Je;return(Je=Se(W.getFullYear()-_e.getFullYear()))===0&&(Je=Se(W.getMonth()-_e.getMonth()))===0&&(Je=Se(W.getDate()-_e.getDate())),Je}function we(W){switch(W.getDay()){case 0:return new Date(W.getFullYear()-1,11,29);case 1:return W;case 2:return new Date(W.getFullYear(),0,3);case 3:return new Date(W.getFullYear(),0,2);case 4:return new Date(W.getFullYear(),0,1);case 5:return new Date(W.getFullYear()-1,11,31);case 6:return new Date(W.getFullYear()-1,11,30)}}function Me(W){var _e=W.Ja;for(W=new Date(new Date(W.Ka+1900,0,1).getTime());0<_e;){var Se=W.getMonth(),Je=(tt(W.getFullYear())?Ct:At)[Se];if(!(_e>Je-W.getDate())){W.setDate(W.getDate()+_e);break}_e-=Je-W.getDate()+1,W.setDate(1),11>Se?W.setMonth(Se+1):(W.setMonth(0),W.setFullYear(W.getFullYear()+1))}return Se=new Date(W.getFullYear()+1,0,4),_e=we(new Date(W.getFullYear(),0,4)),Se=we(Se),0>=se(_e,W)?0>=se(Se,W)?W.getFullYear()+1:W.getFullYear():W.getFullYear()-1}x>>>=0,N>>>=0,M>>>=0,V>>>=0;var Ee=c()[V+40>>2>>>0];for(var Re in V={kb:c()[V>>2>>>0],jb:c()[V+4>>2>>>0],Ma:c()[V+8>>2>>>0],Qa:c()[V+12>>2>>>0],Na:c()[V+16>>2>>>0],Ka:c()[V+20>>2>>>0],Ga:c()[V+24>>2>>>0],Ja:c()[V+28>>2>>>0],sb:c()[V+32>>2>>>0],ib:c()[V+36>>2>>>0],lb:Ee?Ue(Ee):""},M=Ue(M),Ee={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})M=M.replace(new RegExp(Re,"g"),Ee[Re]);var Ut="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Vt="January February March April May June July August September October November December".split(" ");for(Re in Ee={"%a":W=>Ut[W.Ga].substring(0,3),"%A":W=>Ut[W.Ga],"%b":W=>Vt[W.Na].substring(0,3),"%B":W=>Vt[W.Na],"%C":W=>ne((W.Ka+1900)/100|0,2),"%d":W=>ne(W.Qa,2),"%e":W=>Z(W.Qa,2," "),"%g":W=>Me(W).toString().substring(2),"%G":W=>Me(W),"%H":W=>ne(W.Ma,2),"%I":W=>((W=W.Ma)==0?W=12:12<W&&(W-=12),ne(W,2)),"%j":W=>{for(var _e=0,Se=0;Se<=W.Na-1;_e+=(tt(W.Ka+1900)?Ct:At)[Se++]);return ne(W.Qa+_e,3)},"%m":W=>ne(W.Na+1,2),"%M":W=>ne(W.jb,2),"%n":()=>`
`,"%p":W=>0<=W.Ma&&12>W.Ma?"AM":"PM","%S":W=>ne(W.kb,2),"%t":()=>"	","%u":W=>W.Ga||7,"%U":W=>ne(Math.floor((W.Ja+7-W.Ga)/7),2),"%V":W=>{var _e=Math.floor((W.Ja+7-(W.Ga+6)%7)/7);if(2>=(W.Ga+371-W.Ja-2)%7&&_e++,_e)_e==53&&((Se=(W.Ga+371-W.Ja)%7)==4||Se==3&&tt(W.Ka)||(_e=1));else{_e=52;var Se=(W.Ga+7-W.Ja-1)%7;(Se==4||Se==5&&tt(W.Ka%400-1))&&_e++}return ne(_e,2)},"%w":W=>W.Ga,"%W":W=>ne(Math.floor((W.Ja+7-(W.Ga+6)%7)/7),2),"%y":W=>(W.Ka+1900).toString().substring(2),"%Y":W=>W.Ka+1900,"%z":W=>{var _e=0<=(W=W.ib);return W=Math.abs(W)/60,(_e?"+":"-")+("0000"+(W/60*100+W%60)).slice(-4)},"%Z":W=>W.lb,"%%":()=>"%"},M=M.replace(/%%/g,"\0\0"),Ee)M.includes(Re)&&(M=M.replace(new RegExp(Re,"g"),Ee[Re](V)));return Re=function(W){var _e=Array(U(W)+1);return X(W,_e,0,_e.length),_e}(M=M.replace(/\0\0/g,"%")),Re.length>N?0:(Wt(Re,x),Re.length-1)}le.Pa();var qt=[null,Ke,Ye,B,Q,F,oe,ce,he,De,H,de,me,Le,Xe,_t,mt,yt,vt,St,kt,Ot,xt,It,Et],Kt={b:function(x,N,M){throw new j(x>>>=0).Pa(N>>>0,M>>>0),x},N:function(x){Dt(x>>>0,!y,1,!T,131072,!1),le.Sa()},k:function(x){x>>>=0,S?postMessage({cmd:"cleanupThread",thread:x}):ze(x)},I:q,h:Q,T:F,E:oe,G:ce,U:he,R:De,J:H,Q:de,o:me,F:Le,C:Xe,S:_t,D:mt,q:()=>!0,A:function(x,N){(x>>>=0)==N>>>0?setTimeout(()=>rt()):S?postMessage({targetThread:x,cmd:"checkMailbox"}):(x=le.Fa[x])&&x.postMessage({cmd:"checkMailbox"})},L:function(){return-1},M:st,p:function(x){w&&le.Fa[x>>>0].ref()},t:function(x,N,M){x=N+2097152>>>0<4194305-!!x?(x>>>0)+4294967296*N:NaN,M>>>=0,x=new Date(1e3*x),c()[M>>2>>>0]=x.getUTCSeconds(),c()[M+4>>2>>>0]=x.getUTCMinutes(),c()[M+8>>2>>>0]=x.getUTCHours(),c()[M+12>>2>>>0]=x.getUTCDate(),c()[M+16>>2>>>0]=x.getUTCMonth(),c()[M+20>>2>>>0]=x.getUTCFullYear()-1900,c()[M+24>>2>>>0]=x.getUTCDay(),x=(x.getTime()-Date.UTC(x.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,c()[M+28>>2>>>0]=x},u:function(x,N,M){x=N+2097152>>>0<4194305-!!x?(x>>>0)+4294967296*N:NaN,M>>>=0,x=new Date(1e3*x),c()[M>>2>>>0]=x.getSeconds(),c()[M+4>>2>>>0]=x.getMinutes(),c()[M+8>>2>>>0]=x.getHours(),c()[M+12>>2>>>0]=x.getDate(),c()[M+16>>2>>>0]=x.getMonth(),c()[M+20>>2>>>0]=x.getFullYear()-1900,c()[M+24>>2>>>0]=x.getDay(),N=(tt(x.getFullYear())?gt:bt)[x.getMonth()]+x.getDate()-1|0,c()[M+28>>2>>>0]=N,c()[M+36>>2>>>0]=-60*x.getTimezoneOffset(),N=new Date(x.getFullYear(),6,1).getTimezoneOffset();var V=new Date(x.getFullYear(),0,1).getTimezoneOffset();x=0|(N!=V&&x.getTimezoneOffset()==Math.min(V,N)),c()[M+32>>2>>>0]=x},v:function(x){x>>>=0;var N=new Date(c()[x+20>>2>>>0]+1900,c()[x+16>>2>>>0],c()[x+12>>2>>>0],c()[x+8>>2>>>0],c()[x+4>>2>>>0],c()[x>>2>>>0],0),M=c()[x+32>>2>>>0],V=N.getTimezoneOffset(),Z=new Date(N.getFullYear(),6,1).getTimezoneOffset(),ne=new Date(N.getFullYear(),0,1).getTimezoneOffset(),se=Math.min(ne,Z);return 0>M?c()[x+32>>2>>>0]=+(Z!=ne&&se==V):0<M!=(se==V)&&(Z=Math.max(ne,Z),N.setTime(N.getTime()+6e4*((0<M?se:Z)-V))),c()[x+24>>2>>>0]=N.getDay(),M=(tt(N.getFullYear())?gt:bt)[N.getMonth()]+N.getDate()-1|0,c()[x+28>>2>>>0]=M,c()[x>>2>>>0]=N.getSeconds(),c()[x+4>>2>>>0]=N.getMinutes(),c()[x+8>>2>>>0]=N.getHours(),c()[x+12>>2>>>0]=N.getDate(),c()[x+16>>2>>>0]=N.getMonth(),c()[x+20>>2>>>0]=N.getYear(),x=N.getTime()/1e3,Lt((Ce=x,1<=+Math.abs(Ce)?0<Ce?+Math.floor(Ce/4294967296)>>>0:~~+Math.ceil((Ce-+(~~Ce>>>0))/4294967296)>>>0:0)),x>>>0},r:yt,s:vt,z:function(x,N,M){function V(Ee){return(Ee=Ee.toTimeString().match(/\(([A-Za-z ]+)\)$/))?Ee[1]:"GMT"}x>>>=0,N>>>=0,M>>>=0;var Z=new Date().getFullYear(),ne=new Date(Z,0,1),se=new Date(Z,6,1);Z=ne.getTimezoneOffset();var we=se.getTimezoneOffset(),Me=Math.max(Z,we);f()[x>>2>>>0]=60*Me,c()[N>>2>>>0]=+(Z!=we),x=V(ne),N=V(se),x=Tt(x),N=Tt(N),we<Z?(f()[M>>2>>>0]=x,f()[M+4>>2>>>0]=N):(f()[M>>2>>>0]=N,f()[M+4>>2>>>0]=x)},c:()=>{Oe("")},l:function(){},i:function(){return Date.now()},V:()=>{throw ke+=1,"unwind"},B:function(){return 4294901760},e:()=>performance.timeOrigin+performance.now(),f:function(){return w?n(3993).cpus().length:navigator.hardwareConcurrency},K:function(x,N,M,V){for(le.pb=N>>>0,ct.length=M,N=V>>>0>>3,V=0;V<M;V++)ct[V]=h()[N+V>>>0];return qt[x].apply(null,ct)},y:function(x){x>>>=0;var N=l().length;if(x<=N||4294901760<x)return!1;for(var M=1;4>=M;M*=2){var V=N*(1+.2/M);V=Math.min(V,x+100663296);var Z=Math;V=Math.max(x,V);e:{Z=Z.min.call(Z,4294901760,V+(65536-V%65536)%65536)-K.buffer.byteLength+65535>>>16;try{K.grow(Z),ge();var ne=1;break e}catch{}ne=void 0}if(ne)return!0}return!1},O:St,P:kt,j:Ze,g:Ot,n:xt,w:It,m:Et,x:function(x,N){return x>>>=0,N>>>=0,Pt(l().subarray(x>>>0,x+N>>>0)),0},a:K||d.wasmMemory,H:$t,d:function(x,N,M,V){return $t(x>>>0,N>>>0,M>>>0,V>>>0)}};(function(){function x(M,V){return M=M.exports,G=M=function(Z){var ne=we=>()=>we()>>>0,se=we=>Me=>we(Me)>>>0;return(Z=Object.assign({},Z)).__errno_location=ne(Z.__errno_location),Z.pthread_self=ne(Z.pthread_self),Z.malloc=se(Z.malloc),Z.stackSave=ne(Z.stackSave),Z.stackAlloc=se(Z.stackAlloc),Z}(M),le.Ta.push(G.sa),xe=G.ta,Te.unshift(G.W),J=V,$e(),M}var N={a:Kt};if(Ve(),d.instantiateWasm)try{return d.instantiateWasm(N,x)}catch(M){C("Module.instantiateWasm callback failed with error: "+M),i(M)}(function(M,V){var Z=Ie;return D||typeof WebAssembly.instantiateStreaming!="function"||Fe(Z)||Z.startsWith("file://")||w||typeof fetch!="function"?Qe(Z,M,V):fetch(Z,{credentials:"same-origin"}).then(ne=>WebAssembly.instantiateStreaming(ne,M).then(V,function(se){return C("wasm streaming compile failed: "+se),C("falling back to ArrayBuffer instantiation"),Qe(Z,M,V)}))})(N,function(M){x(M.instance,M.module)}).catch(i)})(),d._OrtInit=(x,N)=>(d._OrtInit=G.X)(x,N),d._OrtGetLastError=(x,N)=>(d._OrtGetLastError=G.Y)(x,N),d._OrtCreateSessionOptions=(x,N,M,V,Z,ne,se,we,Me,Ee)=>(d._OrtCreateSessionOptions=G.Z)(x,N,M,V,Z,ne,se,we,Me,Ee),d._OrtAppendExecutionProvider=(x,N)=>(d._OrtAppendExecutionProvider=G._)(x,N),d._OrtAddSessionConfigEntry=(x,N,M)=>(d._OrtAddSessionConfigEntry=G.$)(x,N,M),d._OrtReleaseSessionOptions=x=>(d._OrtReleaseSessionOptions=G.aa)(x),d._OrtCreateSession=(x,N,M)=>(d._OrtCreateSession=G.ba)(x,N,M),d._OrtReleaseSession=x=>(d._OrtReleaseSession=G.ca)(x),d._OrtGetInputOutputCount=(x,N,M)=>(d._OrtGetInputOutputCount=G.da)(x,N,M),d._OrtGetInputName=(x,N)=>(d._OrtGetInputName=G.ea)(x,N),d._OrtGetOutputName=(x,N)=>(d._OrtGetOutputName=G.fa)(x,N),d._OrtFree=x=>(d._OrtFree=G.ga)(x),d._OrtCreateTensor=(x,N,M,V,Z)=>(d._OrtCreateTensor=G.ha)(x,N,M,V,Z),d._OrtGetTensorData=(x,N,M,V,Z)=>(d._OrtGetTensorData=G.ia)(x,N,M,V,Z),d._OrtReleaseTensor=x=>(d._OrtReleaseTensor=G.ja)(x),d._OrtCreateRunOptions=(x,N,M,V)=>(d._OrtCreateRunOptions=G.ka)(x,N,M,V),d._OrtAddRunConfigEntry=(x,N,M)=>(d._OrtAddRunConfigEntry=G.la)(x,N,M),d._OrtReleaseRunOptions=x=>(d._OrtReleaseRunOptions=G.ma)(x),d._OrtRun=(x,N,M,V,Z,ne,se,we)=>(d._OrtRun=G.na)(x,N,M,V,Z,ne,se,we),d._OrtEndProfiling=x=>(d._OrtEndProfiling=G.oa)(x);var it=d._pthread_self=()=>(it=d._pthread_self=G.pa)(),Nt=d._malloc=x=>(Nt=d._malloc=G.qa)(x);d._free=x=>(d._free=G.ra)(x),d.__emscripten_tls_init=()=>(d.__emscripten_tls_init=G.sa)();var Dt=d.__emscripten_thread_init=(x,N,M,V,Z,ne)=>(Dt=d.__emscripten_thread_init=G.ua)(x,N,M,V,Z,ne);d.__emscripten_thread_crashed=()=>(d.__emscripten_thread_crashed=G.va)();var ot,Rt=(x,N,M,V)=>(Rt=G.wa)(x,N,M,V),dt=x=>(dt=G.xa)(x),ft=d.__emscripten_thread_exit=x=>(ft=d.__emscripten_thread_exit=G.ya)(x),Ft=d.__emscripten_check_mailbox=()=>(Ft=d.__emscripten_check_mailbox=G.za)(),Lt=x=>(Lt=G.Aa)(x),Mt=(x,N)=>(Mt=G.Ba)(x,N),ht=()=>(ht=G.Ca)(),at=x=>(at=G.Da)(x),pt=x=>(pt=G.Ea)(x);function jt(){function x(){if(!ot&&(ot=!0,d.calledRun=!0,!fe)&&(S||Ge(Te),u(d),d.onRuntimeInitialized&&d.onRuntimeInitialized(),!S)){if(d.postRun)for(typeof d.postRun=="function"&&(d.postRun=[d.postRun]);d.postRun.length;){var N=d.postRun.shift();pe.unshift(N)}Ge(pe)}}if(!(0<Ne))if(S)u(d),S||Ge(Te),startWorker(d);else{if(d.preRun)for(typeof d.preRun=="function"&&(d.preRun=[d.preRun]);d.preRun.length;)ve.unshift(d.preRun.shift());Ge(ve),0<Ne||(d.setStatus?(d.setStatus("Running..."),setTimeout(function(){setTimeout(function(){d.setStatus("")},1),x()},1)):x())}}if(d.keepRuntimeAlive=Pe,d.wasmMemory=K,d.stackAlloc=pt,d.stackSave=ht,d.stackRestore=at,d.UTF8ToString=Ue,d.stringToUTF8=re,d.lengthBytesUTF8=U,d.ExitStatus=je,d.PThread=le,Ae=function x(){ot||jt(),ot||(Ae=x)},d.preInit)for(typeof d.preInit=="function"&&(d.preInit=[d.preInit]);0<d.preInit.length;)d.preInit.pop()();return jt(),o.ready});a.exports=r},932:(a,e,n)=>{var t,r=(t=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0,typeof __filename<"u"&&(t=t||__filename),function(o={}){var s,l,c=o;c.ready=new Promise((R,j)=>{s=R,l=j});var f,h,u,i=Object.assign({},c),d="./this.program",p=(R,j)=>{throw j},_=typeof window=="object",m=typeof importScripts=="function",g=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",b="";if(g){var v=n(1384),T=n(908);b=m?T.dirname(b)+"/":__dirname+"/",f=(R,j)=>(R=R.startsWith("file://")?new URL(R):T.normalize(R),v.readFileSync(R,j?void 0:"utf8")),u=R=>((R=f(R,!0)).buffer||(R=new Uint8Array(R)),R),h=(R,j,B,q=!0)=>{R=R.startsWith("file://")?new URL(R):T.normalize(R),v.readFile(R,q?void 0:"utf8",(Q,F)=>{Q?B(Q):j(q?F.buffer:F)})},!c.thisProgram&&1<process.argv.length&&(d=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),p=(R,j)=>{throw process.exitCode=R,j},c.inspect=()=>"[Emscripten Module object]"}else(_||m)&&(m?b=self.location.href:typeof document<"u"&&document.currentScript&&(b=document.currentScript.src),t&&(b=t),b=b.indexOf("blob:")!==0?b.substr(0,b.replace(/[?#].*/,"").lastIndexOf("/")+1):"",f=R=>{var j=new XMLHttpRequest;return j.open("GET",R,!1),j.send(null),j.responseText},m&&(u=R=>{var j=new XMLHttpRequest;return j.open("GET",R,!1),j.responseType="arraybuffer",j.send(null),new Uint8Array(j.response)}),h=(R,j,B)=>{var q=new XMLHttpRequest;q.open("GET",R,!0),q.responseType="arraybuffer",q.onload=()=>{q.status==200||q.status==0&&q.response?j(q.response):B()},q.onerror=B,q.send(null)});var y,w=c.print||console.log.bind(console),S=c.printErr||console.error.bind(console);Object.assign(c,i),i=null,c.thisProgram&&(d=c.thisProgram),c.quit&&(p=c.quit),c.wasmBinary&&(y=c.wasmBinary);var O=c.noExitRuntime||!0;typeof WebAssembly!="object"&&ae("no native wasm support detected");var P,E,A,$,k,D,I=!1;function C(){var R=P.buffer;c.HEAP8=A=new Int8Array(R),c.HEAP16=new Int16Array(R),c.HEAP32=k=new Int32Array(R),c.HEAPU8=$=new Uint8Array(R),c.HEAPU16=new Uint16Array(R),c.HEAPU32=D=new Uint32Array(R),c.HEAPF32=new Float32Array(R),c.HEAPF64=new Float64Array(R)}var L=[],K=[],G=[];function J(){var R=c.preRun.shift();L.unshift(R)}var Y,te,ee=0,ie=null;function ae(R){throw c.onAbort&&c.onAbort(R),S(R="Aborted("+R+")"),I=!0,R=new WebAssembly.RuntimeError(R+". Build with -sASSERTIONS for more info."),l(R),R}function ue(R){return R.startsWith("data:application/octet-stream;base64,")}if(!ue(Y="ort-wasm.wasm")){var fe=Y;Y=c.locateFile?c.locateFile(fe,b):b+fe}function ge(R){if(R==Y&&y)return new Uint8Array(y);if(u)return u(R);throw"both async and sync fetching of the wasm failed"}function be(R,j,B){return function(q){if(!y&&(_||m)){if(typeof fetch=="function"&&!q.startsWith("file://"))return fetch(q,{credentials:"same-origin"}).then(Q=>{if(!Q.ok)throw"failed to load wasm binary file at '"+q+"'";return Q.arrayBuffer()}).catch(()=>ge(q));if(h)return new Promise((Q,F)=>{h(q,U=>Q(new Uint8Array(U)),F)})}return Promise.resolve().then(()=>ge(q))}(R).then(q=>WebAssembly.instantiate(q,j)).then(q=>q).then(B,q=>{S("failed to asynchronously prepare wasm: "+q),ae(q)})}function xe(R){this.name="ExitStatus",this.message=`Program terminated with exit(${R})`,this.status=R}var ve=R=>{for(;0<R.length;)R.shift()(c)};function Te(R){this.qa=R-24,this.va=function(j){D[this.qa+4>>2>>>0]=j},this.ua=function(j){D[this.qa+8>>2>>>0]=j},this.sa=function(j,B){this.ta(),this.va(j),this.ua(B)},this.ta=function(){D[this.qa+16>>2>>>0]=0}}var pe,ke=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Pe=(R,j,B)=>{var q=(j>>>=0)+B;for(B=j;R[B]&&!(B>=q);)++B;if(16<B-j&&R.buffer&&ke)return ke.decode(R.subarray(j,B));for(q="";j<B;){var Q=R[j++];if(128&Q){var F=63&R[j++];if((224&Q)==192)q+=String.fromCharCode((31&Q)<<6|F);else{var U=63&R[j++];65536>(Q=(240&Q)==224?(15&Q)<<12|F<<6|U:(7&Q)<<18|F<<12|U<<6|63&R[j++])?q+=String.fromCharCode(Q):(Q-=65536,q+=String.fromCharCode(55296|Q>>10,56320|1023&Q))}}else q+=String.fromCharCode(Q)}return q},Ie=(R,j)=>(R>>>=0)?Pe($,R,j):"",Ce=R=>{for(var j=0,B=0;B<R.length;++B){var q=R.charCodeAt(B);127>=q?j++:2047>=q?j+=2:55296<=q&&57343>=q?(j+=4,++B):j+=3}return j},Ne=(R,j,B,q)=>{if(!(0<q))return 0;var Q=B>>>=0;q=B+q-1;for(var F=0;F<R.length;++F){var U=R.charCodeAt(F);if(55296<=U&&57343>=U&&(U=65536+((1023&U)<<10)|1023&R.charCodeAt(++F)),127>=U){if(B>=q)break;j[B++>>>0]=U}else{if(2047>=U){if(B+1>=q)break;j[B++>>>0]=192|U>>6}else{if(65535>=U){if(B+2>=q)break;j[B++>>>0]=224|U>>12}else{if(B+3>=q)break;j[B++>>>0]=240|U>>18,j[B++>>>0]=128|U>>12&63}j[B++>>>0]=128|U>>6&63}j[B++>>>0]=128|63&U}}return j[B>>>0]=0,B-Q},Ae=R=>R%4==0&&(R%100!=0||R%400==0),Ve=[0,31,60,91,121,152,182,213,244,274,305,335],$e=[0,31,59,90,120,151,181,212,243,273,304,334],Oe=R=>{var j=Ce(R)+1,B=qe(j);return B&&Ne(R,$,B,j),B},Fe={},We=()=>{if(!pe){var R,j={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:d||"./this.program"};for(R in Fe)Fe[R]===void 0?delete j[R]:j[R]=Fe[R];var B=[];for(R in j)B.push(`${R}=${j[R]}`);pe=B}return pe},Qe=[null,[],[]],je=R=>(je=(()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return q=>crypto.getRandomValues(q);if(g)try{var j=n(760);if(j.randomFillSync)return q=>j.randomFillSync(q);var B=j.randomBytes;return q=>(q.set(B(q.byteLength)),q)}catch{}ae("initRandomDevice")})())(R),Be=[31,29,31,30,31,30,31,31,30,31,30,31],ze=[31,28,31,30,31,30,31,31,30,31,30,31];function He(R,j,B,q){function Q(H,de,me){for(H=typeof H=="number"?H.toString():H||"";H.length<de;)H=me[0]+H;return H}function F(H,de){return Q(H,de,"0")}function U(H,de){function me(Xe){return 0>Xe?-1:0<Xe?1:0}var Le;return(Le=me(H.getFullYear()-de.getFullYear()))===0&&(Le=me(H.getMonth()-de.getMonth()))===0&&(Le=me(H.getDate()-de.getDate())),Le}function X(H){switch(H.getDay()){case 0:return new Date(H.getFullYear()-1,11,29);case 1:return H;case 2:return new Date(H.getFullYear(),0,3);case 3:return new Date(H.getFullYear(),0,2);case 4:return new Date(H.getFullYear(),0,1);case 5:return new Date(H.getFullYear()-1,11,31);case 6:return new Date(H.getFullYear()-1,11,30)}}function re(H){var de=H.ma;for(H=new Date(new Date(H.na+1900,0,1).getTime());0<de;){var me=H.getMonth(),Le=(Ae(H.getFullYear())?Be:ze)[me];if(!(de>Le-H.getDate())){H.setDate(H.getDate()+de);break}de-=Le-H.getDate()+1,H.setDate(1),11>me?H.setMonth(me+1):(H.setMonth(0),H.setFullYear(H.getFullYear()+1))}return me=new Date(H.getFullYear()+1,0,4),de=X(new Date(H.getFullYear(),0,4)),me=X(me),0>=U(de,H)?0>=U(me,H)?H.getFullYear()+1:H.getFullYear():H.getFullYear()-1}R>>>=0,j>>>=0,B>>>=0;var oe=k[40+(q>>>=0)>>2>>>0];for(var ce in q={ya:k[q>>2>>>0],xa:k[q+4>>2>>>0],oa:k[q+8>>2>>>0],ra:k[q+12>>2>>>0],pa:k[q+16>>2>>>0],na:k[q+20>>2>>>0],ha:k[q+24>>2>>>0],ma:k[q+28>>2>>>0],Aa:k[q+32>>2>>>0],wa:k[q+36>>2>>>0],za:oe?Ie(oe):""},B=Ie(B),oe={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})B=B.replace(new RegExp(ce,"g"),oe[ce]);var he="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),De="January February March April May June July August September October November December".split(" ");for(ce in oe={"%a":H=>he[H.ha].substring(0,3),"%A":H=>he[H.ha],"%b":H=>De[H.pa].substring(0,3),"%B":H=>De[H.pa],"%C":H=>F((H.na+1900)/100|0,2),"%d":H=>F(H.ra,2),"%e":H=>Q(H.ra,2," "),"%g":H=>re(H).toString().substring(2),"%G":H=>re(H),"%H":H=>F(H.oa,2),"%I":H=>((H=H.oa)==0?H=12:12<H&&(H-=12),F(H,2)),"%j":H=>{for(var de=0,me=0;me<=H.pa-1;de+=(Ae(H.na+1900)?Be:ze)[me++]);return F(H.ra+de,3)},"%m":H=>F(H.pa+1,2),"%M":H=>F(H.xa,2),"%n":()=>`
`,"%p":H=>0<=H.oa&&12>H.oa?"AM":"PM","%S":H=>F(H.ya,2),"%t":()=>"	","%u":H=>H.ha||7,"%U":H=>F(Math.floor((H.ma+7-H.ha)/7),2),"%V":H=>{var de=Math.floor((H.ma+7-(H.ha+6)%7)/7);if(2>=(H.ha+371-H.ma-2)%7&&de++,de)de==53&&((me=(H.ha+371-H.ma)%7)==4||me==3&&Ae(H.na)||(de=1));else{de=52;var me=(H.ha+7-H.ma-1)%7;(me==4||me==5&&Ae(H.na%400-1))&&de++}return F(de,2)},"%w":H=>H.ha,"%W":H=>F(Math.floor((H.ma+7-(H.ha+6)%7)/7),2),"%y":H=>(H.na+1900).toString().substring(2),"%Y":H=>H.na+1900,"%z":H=>{var de=0<=(H=H.wa);return H=Math.abs(H)/60,(de?"+":"-")+("0000"+(H/60*100+H%60)).slice(-4)},"%Z":H=>H.za,"%%":()=>"%"},B=B.replace(/%%/g,"\0\0"),oe)B.includes(ce)&&(B=B.replace(new RegExp(ce,"g"),oe[ce](q)));return ce=function(H){var de=Array(Ce(H)+1);return Ne(H,de,0,de.length),de}(B=B.replace(/\0\0/g,"%")),ce.length>j?0:(A.set(ce,R>>>0),ce.length-1)}var et={a:function(R,j,B){throw new Te(R>>>=0).sa(j>>>0,B>>>0),R},e:function(){return 0},I:function(){},y:function(){},A:function(){},K:function(){return 0},G:function(){},B:function(){},F:function(){},g:function(){},z:function(){},w:function(){},H:function(){},x:function(){},k:()=>!0,n:function(R,j,B){R=j+2097152>>>0<4194305-!!R?(R>>>0)+4294967296*j:NaN,B>>>=0,R=new Date(1e3*R),k[B>>2>>>0]=R.getUTCSeconds(),k[B+4>>2>>>0]=R.getUTCMinutes(),k[B+8>>2>>>0]=R.getUTCHours(),k[B+12>>2>>>0]=R.getUTCDate(),k[B+16>>2>>>0]=R.getUTCMonth(),k[B+20>>2>>>0]=R.getUTCFullYear()-1900,k[B+24>>2>>>0]=R.getUTCDay(),k[B+28>>2>>>0]=(R.getTime()-Date.UTC(R.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},o:function(R,j,B){R=j+2097152>>>0<4194305-!!R?(R>>>0)+4294967296*j:NaN,B>>>=0,R=new Date(1e3*R),k[B>>2>>>0]=R.getSeconds(),k[B+4>>2>>>0]=R.getMinutes(),k[B+8>>2>>>0]=R.getHours(),k[B+12>>2>>>0]=R.getDate(),k[B+16>>2>>>0]=R.getMonth(),k[B+20>>2>>>0]=R.getFullYear()-1900,k[B+24>>2>>>0]=R.getDay(),k[B+28>>2>>>0]=(Ae(R.getFullYear())?Ve:$e)[R.getMonth()]+R.getDate()-1|0,k[B+36>>2>>>0]=-60*R.getTimezoneOffset(),j=new Date(R.getFullYear(),6,1).getTimezoneOffset();var q=new Date(R.getFullYear(),0,1).getTimezoneOffset();k[B+32>>2>>>0]=0|(j!=q&&R.getTimezoneOffset()==Math.min(q,j))},p:function(R){R>>>=0;var j=new Date(k[R+20>>2>>>0]+1900,k[R+16>>2>>>0],k[R+12>>2>>>0],k[R+8>>2>>>0],k[R+4>>2>>>0],k[R>>2>>>0],0),B=k[R+32>>2>>>0],q=j.getTimezoneOffset(),Q=new Date(j.getFullYear(),6,1).getTimezoneOffset(),F=new Date(j.getFullYear(),0,1).getTimezoneOffset(),U=Math.min(F,Q);return 0>B?k[R+32>>2>>>0]=+(Q!=F&&U==q):0<B!=(U==q)&&(Q=Math.max(F,Q),j.setTime(j.getTime()+6e4*((0<B?U:Q)-q))),k[R+24>>2>>>0]=j.getDay(),k[R+28>>2>>>0]=(Ae(j.getFullYear())?Ve:$e)[j.getMonth()]+j.getDate()-1|0,k[R>>2>>>0]=j.getSeconds(),k[R+4>>2>>>0]=j.getMinutes(),k[R+8>>2>>>0]=j.getHours(),k[R+12>>2>>>0]=j.getDate(),k[R+16>>2>>>0]=j.getMonth(),k[R+20>>2>>>0]=j.getYear(),R=j.getTime()/1e3,Ke((te=R,1<=+Math.abs(te)?0<te?+Math.floor(te/4294967296)>>>0:~~+Math.ceil((te-+(~~te>>>0))/4294967296)>>>0:0)),R>>>0},l:function(){return-52},m:function(){},u:function(R,j,B){function q(re){return(re=re.toTimeString().match(/\(([A-Za-z ]+)\)$/))?re[1]:"GMT"}B>>>=0;var Q=new Date().getFullYear(),F=new Date(Q,0,1),U=new Date(Q,6,1);Q=F.getTimezoneOffset();var X=U.getTimezoneOffset();D[R>>>0>>2>>>0]=60*Math.max(Q,X),k[j>>>0>>2>>>0]=+(Q!=X),R=q(F),j=q(U),R=Oe(R),j=Oe(j),X<Q?(D[B>>2>>>0]=R,D[B+4>>2>>>0]=j):(D[B>>2>>>0]=j,D[B+4>>2>>>0]=R)},d:()=>{ae("")},h:function(){return Date.now()},v:function(){return 4294901760},b:()=>performance.now(),J:function(R,j,B){return j>>>=0,$.copyWithin(R>>>0>>>0,j>>>0,j+(B>>>0)>>>0)},t:function(R){R>>>=0;var j=$.length;if(4294901760<R)return!1;for(var B=1;4>=B;B*=2){var q=j*(1+.2/B);q=Math.min(q,R+100663296);var Q=Math;q=Math.max(R,q);e:{Q=Q.min.call(Q,4294901760,q+(65536-q%65536)%65536)-P.buffer.byteLength+65535>>>16;try{P.grow(Q),C();var F=1;break e}catch{}F=void 0}if(F)return!0}return!1},D:function(R,j){R>>>=0,j>>>=0;var B=0;return We().forEach(function(q,Q){var F=j+B;for(Q=D[R+4*Q>>2>>>0]=F,F=0;F<q.length;++F)A[Q++>>0>>>0]=q.charCodeAt(F);A[Q>>0>>>0]=0,B+=q.length+1}),0},E:function(R,j){R>>>=0,j>>>=0;var B=We();D[R>>2>>>0]=B.length;var q=0;return B.forEach(function(Q){q+=Q.length+1}),D[j>>2>>>0]=q,0},s:R=>{O||(c.onExit&&c.onExit(R),I=!0),p(R,new xe(R))},f:()=>52,j:function(){return 52},q:function(){return 70},i:function(R,j,B,q){j>>>=0,B>>>=0,q>>>=0;for(var Q=0,F=0;F<B;F++){var U=D[j>>2>>>0],X=D[j+4>>2>>>0];j+=8;for(var re=0;re<X;re++){var oe=$[U+re>>>0],ce=Qe[R];oe===0||oe===10?((R===1?w:S)(Pe(ce,0)),ce.length=0):ce.push(oe)}Q+=X}return D[q>>2>>>0]=Q,0},r:function(R,j){return R>>>=0,je($.subarray(R>>>0,R+(j>>>0)>>>0)),0},C:He,c:function(R,j,B,q){return He(R>>>0,j>>>0,B>>>0,q>>>0)}};(function(){function R(B){if(B=B.exports,E=B=function(Q){var F=X=>()=>X()>>>0,U=X=>re=>X(re)>>>0;return(Q=Object.assign({},Q)).__errno_location=F(Q.__errno_location),Q.malloc=U(Q.malloc),Q.stackSave=F(Q.stackSave),Q.stackAlloc=U(Q.stackAlloc),Q}(B),P=E.L,C(),K.unshift(E.M),ee--,c.monitorRunDependencies&&c.monitorRunDependencies(ee),ee==0&&ie){var q=ie;ie=null,q()}return B}var j={a:et};if(ee++,c.monitorRunDependencies&&c.monitorRunDependencies(ee),c.instantiateWasm)try{return c.instantiateWasm(j,R)}catch(B){S("Module.instantiateWasm callback failed with error: "+B),l(B)}(function(B,q){var Q=Y;return y||typeof WebAssembly.instantiateStreaming!="function"||ue(Q)||Q.startsWith("file://")||g||typeof fetch!="function"?be(Q,B,q):fetch(Q,{credentials:"same-origin"}).then(F=>WebAssembly.instantiateStreaming(F,B).then(q,function(U){return S("wasm streaming compile failed: "+U),S("falling back to ArrayBuffer instantiation"),be(Q,B,q)}))})(j,function(B){R(B.instance)}).catch(l)})(),c._OrtInit=(R,j)=>(c._OrtInit=E.N)(R,j),c._OrtGetLastError=(R,j)=>(c._OrtGetLastError=E.O)(R,j),c._OrtCreateSessionOptions=(R,j,B,q,Q,F,U,X,re,oe)=>(c._OrtCreateSessionOptions=E.P)(R,j,B,q,Q,F,U,X,re,oe),c._OrtAppendExecutionProvider=(R,j)=>(c._OrtAppendExecutionProvider=E.Q)(R,j),c._OrtAddSessionConfigEntry=(R,j,B)=>(c._OrtAddSessionConfigEntry=E.R)(R,j,B),c._OrtReleaseSessionOptions=R=>(c._OrtReleaseSessionOptions=E.S)(R),c._OrtCreateSession=(R,j,B)=>(c._OrtCreateSession=E.T)(R,j,B),c._OrtReleaseSession=R=>(c._OrtReleaseSession=E.U)(R),c._OrtGetInputOutputCount=(R,j,B)=>(c._OrtGetInputOutputCount=E.V)(R,j,B),c._OrtGetInputName=(R,j)=>(c._OrtGetInputName=E.W)(R,j),c._OrtGetOutputName=(R,j)=>(c._OrtGetOutputName=E.X)(R,j),c._OrtFree=R=>(c._OrtFree=E.Y)(R),c._OrtCreateTensor=(R,j,B,q,Q)=>(c._OrtCreateTensor=E.Z)(R,j,B,q,Q),c._OrtGetTensorData=(R,j,B,q,Q)=>(c._OrtGetTensorData=E._)(R,j,B,q,Q),c._OrtReleaseTensor=R=>(c._OrtReleaseTensor=E.$)(R),c._OrtCreateRunOptions=(R,j,B,q)=>(c._OrtCreateRunOptions=E.aa)(R,j,B,q),c._OrtAddRunConfigEntry=(R,j,B)=>(c._OrtAddRunConfigEntry=E.ba)(R,j,B),c._OrtReleaseRunOptions=R=>(c._OrtReleaseRunOptions=E.ca)(R),c._OrtRun=(R,j,B,q,Q,F,U,X)=>(c._OrtRun=E.da)(R,j,B,q,Q,F,U,X),c._OrtEndProfiling=R=>(c._OrtEndProfiling=E.ea)(R);var qe=c._malloc=R=>(qe=c._malloc=E.fa)(R);c._free=R=>(c._free=E.ga)(R);var Ue,Ke=R=>(Ke=E.ia)(R),Ze=()=>(Ze=E.ja)(),le=R=>(le=E.ka)(R),Ge=R=>(Ge=E.la)(R);function Ye(){function R(){if(!Ue&&(Ue=!0,c.calledRun=!0,!I)){if(ve(K),s(c),c.onRuntimeInitialized&&c.onRuntimeInitialized(),c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;){var j=c.postRun.shift();G.unshift(j)}ve(G)}}if(!(0<ee)){if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)J();ve(L),0<ee||(c.setStatus?(c.setStatus("Running..."),setTimeout(function(){setTimeout(function(){c.setStatus("")},1),R()},1)):R())}}if(c.stackAlloc=Ge,c.stackSave=Ze,c.stackRestore=le,c.UTF8ToString=Ie,c.stringToUTF8=(R,j,B)=>Ne(R,$,j,B),c.lengthBytesUTF8=Ce,ie=function R(){Ue||Ye(),Ue||(ie=R)},c.preInit)for(typeof c.preInit=="function"&&(c.preInit=[c.preInit]);0<c.preInit.length;)c.preInit.pop()();return Ye(),o.ready});a.exports=r},4537:a=>{a.exports=function(e,n){for(var t=new Array(arguments.length-1),r=0,o=2,s=!0;o<arguments.length;)t[r++]=arguments[o++];return new Promise(function(l,c){t[r]=function(f){if(s)if(s=!1,f)c(f);else{for(var h=new Array(arguments.length-1),u=0;u<h.length;)h[u++]=arguments[u];l.apply(null,h)}};try{e.apply(n||null,t)}catch(f){s&&(s=!1,c(f))}})}},7419:(a,e)=>{var n=e;n.length=function(l){var c=l.length;if(!c)return 0;for(var f=0;--c%4>1&&l.charAt(c)==="=";)++f;return Math.ceil(3*l.length)/4-f};for(var t=new Array(64),r=new Array(123),o=0;o<64;)r[t[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;n.encode=function(l,c,f){for(var h,u=null,i=[],d=0,p=0;c<f;){var _=l[c++];switch(p){case 0:i[d++]=t[_>>2],h=(3&_)<<4,p=1;break;case 1:i[d++]=t[h|_>>4],h=(15&_)<<2,p=2;break;case 2:i[d++]=t[h|_>>6],i[d++]=t[63&_],p=0}d>8191&&((u||(u=[])).push(String.fromCharCode.apply(String,i)),d=0)}return p&&(i[d++]=t[h],i[d++]=61,p===1&&(i[d++]=61)),u?(d&&u.push(String.fromCharCode.apply(String,i.slice(0,d))),u.join("")):String.fromCharCode.apply(String,i.slice(0,d))};var s="invalid encoding";n.decode=function(l,c,f){for(var h,u=f,i=0,d=0;d<l.length;){var p=l.charCodeAt(d++);if(p===61&&i>1)break;if((p=r[p])===void 0)throw Error(s);switch(i){case 0:h=p,i=1;break;case 1:c[f++]=h<<2|(48&p)>>4,h=p,i=2;break;case 2:c[f++]=(15&h)<<4|(60&p)>>2,h=p,i=3;break;case 3:c[f++]=(3&h)<<6|p,i=0}}if(i===1)throw Error(s);return f-u},n.test=function(l){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(l)}},9211:a=>{function e(){this._listeners={}}a.exports=e,e.prototype.on=function(n,t,r){return(this._listeners[n]||(this._listeners[n]=[])).push({fn:t,ctx:r||this}),this},e.prototype.off=function(n,t){if(n===void 0)this._listeners={};else if(t===void 0)this._listeners[n]=[];else for(var r=this._listeners[n],o=0;o<r.length;)r[o].fn===t?r.splice(o,1):++o;return this},e.prototype.emit=function(n){var t=this._listeners[n];if(t){for(var r=[],o=1;o<arguments.length;)r.push(arguments[o++]);for(o=0;o<t.length;)t[o].fn.apply(t[o++].ctx,r)}return this}},945:a=>{function e(s){return typeof Float32Array<"u"?function(){var l=new Float32Array([-0]),c=new Uint8Array(l.buffer),f=c[3]===128;function h(p,_,m){l[0]=p,_[m]=c[0],_[m+1]=c[1],_[m+2]=c[2],_[m+3]=c[3]}function u(p,_,m){l[0]=p,_[m]=c[3],_[m+1]=c[2],_[m+2]=c[1],_[m+3]=c[0]}function i(p,_){return c[0]=p[_],c[1]=p[_+1],c[2]=p[_+2],c[3]=p[_+3],l[0]}function d(p,_){return c[3]=p[_],c[2]=p[_+1],c[1]=p[_+2],c[0]=p[_+3],l[0]}s.writeFloatLE=f?h:u,s.writeFloatBE=f?u:h,s.readFloatLE=f?i:d,s.readFloatBE=f?d:i}():function(){function l(f,h,u,i){var d=h<0?1:0;if(d&&(h=-h),h===0)f(1/h>0?0:2147483648,u,i);else if(isNaN(h))f(2143289344,u,i);else if(h>34028234663852886e22)f((d<<31|2139095040)>>>0,u,i);else if(h<11754943508222875e-54)f((d<<31|Math.round(h/1401298464324817e-60))>>>0,u,i);else{var p=Math.floor(Math.log(h)/Math.LN2);f((d<<31|p+127<<23|8388607&Math.round(h*Math.pow(2,-p)*8388608))>>>0,u,i)}}function c(f,h,u){var i=f(h,u),d=2*(i>>31)+1,p=i>>>23&255,_=8388607&i;return p===255?_?NaN:d*(1/0):p===0?1401298464324817e-60*d*_:d*Math.pow(2,p-150)*(_+8388608)}s.writeFloatLE=l.bind(null,n),s.writeFloatBE=l.bind(null,t),s.readFloatLE=c.bind(null,r),s.readFloatBE=c.bind(null,o)}(),typeof Float64Array<"u"?function(){var l=new Float64Array([-0]),c=new Uint8Array(l.buffer),f=c[7]===128;function h(p,_,m){l[0]=p,_[m]=c[0],_[m+1]=c[1],_[m+2]=c[2],_[m+3]=c[3],_[m+4]=c[4],_[m+5]=c[5],_[m+6]=c[6],_[m+7]=c[7]}function u(p,_,m){l[0]=p,_[m]=c[7],_[m+1]=c[6],_[m+2]=c[5],_[m+3]=c[4],_[m+4]=c[3],_[m+5]=c[2],_[m+6]=c[1],_[m+7]=c[0]}function i(p,_){return c[0]=p[_],c[1]=p[_+1],c[2]=p[_+2],c[3]=p[_+3],c[4]=p[_+4],c[5]=p[_+5],c[6]=p[_+6],c[7]=p[_+7],l[0]}function d(p,_){return c[7]=p[_],c[6]=p[_+1],c[5]=p[_+2],c[4]=p[_+3],c[3]=p[_+4],c[2]=p[_+5],c[1]=p[_+6],c[0]=p[_+7],l[0]}s.writeDoubleLE=f?h:u,s.writeDoubleBE=f?u:h,s.readDoubleLE=f?i:d,s.readDoubleBE=f?d:i}():function(){function l(f,h,u,i,d,p){var _=i<0?1:0;if(_&&(i=-i),i===0)f(0,d,p+h),f(1/i>0?0:2147483648,d,p+u);else if(isNaN(i))f(0,d,p+h),f(2146959360,d,p+u);else if(i>17976931348623157e292)f(0,d,p+h),f((_<<31|2146435072)>>>0,d,p+u);else{var m;if(i<22250738585072014e-324)f((m=i/5e-324)>>>0,d,p+h),f((_<<31|m/4294967296)>>>0,d,p+u);else{var g=Math.floor(Math.log(i)/Math.LN2);g===1024&&(g=1023),f(4503599627370496*(m=i*Math.pow(2,-g))>>>0,d,p+h),f((_<<31|g+1023<<20|1048576*m&1048575)>>>0,d,p+u)}}}function c(f,h,u,i,d){var p=f(i,d+h),_=f(i,d+u),m=2*(_>>31)+1,g=_>>>20&2047,b=4294967296*(1048575&_)+p;return g===2047?b?NaN:m*(1/0):g===0?5e-324*m*b:m*Math.pow(2,g-1075)*(b+4503599627370496)}s.writeDoubleLE=l.bind(null,n,0,4),s.writeDoubleBE=l.bind(null,t,4,0),s.readDoubleLE=c.bind(null,r,0,4),s.readDoubleBE=c.bind(null,o,4,0)}(),s}function n(s,l,c){l[c]=255&s,l[c+1]=s>>>8&255,l[c+2]=s>>>16&255,l[c+3]=s>>>24}function t(s,l,c){l[c]=s>>>24,l[c+1]=s>>>16&255,l[c+2]=s>>>8&255,l[c+3]=255&s}function r(s,l){return(s[l]|s[l+1]<<8|s[l+2]<<16|s[l+3]<<24)>>>0}function o(s,l){return(s[l]<<24|s[l+1]<<16|s[l+2]<<8|s[l+3])>>>0}a.exports=e(e)},7199:module=>{function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(a){}return null}module.exports=inquire},6662:a=>{a.exports=function(e,n,t){var r=t||8192,o=r>>>1,s=null,l=r;return function(c){if(c<1||c>o)return e(c);l+c>r&&(s=e(r),l=0);var f=n.call(s,l,l+=c);return 7&l&&(l=1+(7|l)),f}}},4997:(a,e)=>{var n=e;n.length=function(t){for(var r=0,o=0,s=0;s<t.length;++s)(o=t.charCodeAt(s))<128?r+=1:o<2048?r+=2:(64512&o)==55296&&(64512&t.charCodeAt(s+1))==56320?(++s,r+=4):r+=3;return r},n.read=function(t,r,o){if(o-r<1)return"";for(var s,l=null,c=[],f=0;r<o;)(s=t[r++])<128?c[f++]=s:s>191&&s<224?c[f++]=(31&s)<<6|63&t[r++]:s>239&&s<365?(s=((7&s)<<18|(63&t[r++])<<12|(63&t[r++])<<6|63&t[r++])-65536,c[f++]=55296+(s>>10),c[f++]=56320+(1023&s)):c[f++]=(15&s)<<12|(63&t[r++])<<6|63&t[r++],f>8191&&((l||(l=[])).push(String.fromCharCode.apply(String,c)),f=0);return l?(f&&l.push(String.fromCharCode.apply(String,c.slice(0,f))),l.join("")):String.fromCharCode.apply(String,c.slice(0,f))},n.write=function(t,r,o){for(var s,l,c=o,f=0;f<t.length;++f)(s=t.charCodeAt(f))<128?r[o++]=s:s<2048?(r[o++]=s>>6|192,r[o++]=63&s|128):(64512&s)==55296&&(64512&(l=t.charCodeAt(f+1)))==56320?(s=65536+((1023&s)<<10)+(1023&l),++f,r[o++]=s>>18|240,r[o++]=s>>12&63|128,r[o++]=s>>6&63|128,r[o++]=63&s|128):(r[o++]=s>>12|224,r[o++]=s>>6&63|128,r[o++]=63&s|128);return o-c}},3442:(a,e)=>{e.__esModule=!0;var n=function(){function t(r){if(!r)throw new TypeError("Invalid argument; `value` has no value.");this.value=t.EMPTY,r&&t.isGuid(r)&&(this.value=r)}return t.isGuid=function(r){var o=r.toString();return r&&(r instanceof t||t.validator.test(o))},t.create=function(){return new t([t.gen(2),t.gen(1),t.gen(1),t.gen(1),t.gen(3)].join("-"))},t.createEmpty=function(){return new t("emptyguid")},t.parse=function(r){return new t(r)},t.raw=function(){return[t.gen(2),t.gen(1),t.gen(1),t.gen(1),t.gen(3)].join("-")},t.gen=function(r){for(var o="",s=0;s<r;s++)o+=(65536*(1+Math.random())|0).toString(16).substring(1);return o},t.prototype.equals=function(r){return t.isGuid(r)&&this.value===r.toString()},t.prototype.isEmpty=function(){return this.value===t.EMPTY},t.prototype.toString=function(){return this.value},t.prototype.toJSON=function(){return{value:this.value}},t.validator=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i"),t.EMPTY="00000000-0000-0000-0000-000000000000",t}();e.Guid=n},2100:(a,e,n)=>{a.exports=n(9482)},9482:(a,e,n)=>{var t=e;function r(){t.util._configure(),t.Writer._configure(t.BufferWriter),t.Reader._configure(t.BufferReader)}t.build="minimal",t.Writer=n(1173),t.BufferWriter=n(3155),t.Reader=n(1408),t.BufferReader=n(593),t.util=n(9693),t.rpc=n(5994),t.roots=n(5054),t.configure=r,r()},1408:(a,e,n)=>{a.exports=c;var t,r=n(9693),o=r.LongBits,s=r.utf8;function l(_,m){return RangeError("index out of range: "+_.pos+" + "+(m||1)+" > "+_.len)}function c(_){this.buf=_,this.pos=0,this.len=_.length}var f,h=typeof Uint8Array<"u"?function(_){if(_ instanceof Uint8Array||Array.isArray(_))return new c(_);throw Error("illegal buffer")}:function(_){if(Array.isArray(_))return new c(_);throw Error("illegal buffer")},u=function(){return r.Buffer?function(_){return(c.create=function(m){return r.Buffer.isBuffer(m)?new t(m):h(m)})(_)}:h};function i(){var _=new o(0,0),m=0;if(!(this.len-this.pos>4)){for(;m<3;++m){if(this.pos>=this.len)throw l(this);if(_.lo=(_.lo|(127&this.buf[this.pos])<<7*m)>>>0,this.buf[this.pos++]<128)return _}return _.lo=(_.lo|(127&this.buf[this.pos++])<<7*m)>>>0,_}for(;m<4;++m)if(_.lo=(_.lo|(127&this.buf[this.pos])<<7*m)>>>0,this.buf[this.pos++]<128)return _;if(_.lo=(_.lo|(127&this.buf[this.pos])<<28)>>>0,_.hi=(_.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return _;if(m=0,this.len-this.pos>4){for(;m<5;++m)if(_.hi=(_.hi|(127&this.buf[this.pos])<<7*m+3)>>>0,this.buf[this.pos++]<128)return _}else for(;m<5;++m){if(this.pos>=this.len)throw l(this);if(_.hi=(_.hi|(127&this.buf[this.pos])<<7*m+3)>>>0,this.buf[this.pos++]<128)return _}throw Error("invalid varint encoding")}function d(_,m){return(_[m-4]|_[m-3]<<8|_[m-2]<<16|_[m-1]<<24)>>>0}function p(){if(this.pos+8>this.len)throw l(this,8);return new o(d(this.buf,this.pos+=4),d(this.buf,this.pos+=4))}c.create=u(),c.prototype._slice=r.Array.prototype.subarray||r.Array.prototype.slice,c.prototype.uint32=(f=4294967295,function(){if(f=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(f=(f|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(f=(f|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(f=(f|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(f=(f|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return f;if((this.pos+=5)>this.len)throw this.pos=this.len,l(this,10);return f}),c.prototype.int32=function(){return 0|this.uint32()},c.prototype.sint32=function(){var _=this.uint32();return _>>>1^-(1&_)|0},c.prototype.bool=function(){return this.uint32()!==0},c.prototype.fixed32=function(){if(this.pos+4>this.len)throw l(this,4);return d(this.buf,this.pos+=4)},c.prototype.sfixed32=function(){if(this.pos+4>this.len)throw l(this,4);return 0|d(this.buf,this.pos+=4)},c.prototype.float=function(){if(this.pos+4>this.len)throw l(this,4);var _=r.float.readFloatLE(this.buf,this.pos);return this.pos+=4,_},c.prototype.double=function(){if(this.pos+8>this.len)throw l(this,4);var _=r.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,_},c.prototype.bytes=function(){var _=this.uint32(),m=this.pos,g=this.pos+_;if(g>this.len)throw l(this,_);return this.pos+=_,Array.isArray(this.buf)?this.buf.slice(m,g):m===g?new this.buf.constructor(0):this._slice.call(this.buf,m,g)},c.prototype.string=function(){var _=this.bytes();return s.read(_,0,_.length)},c.prototype.skip=function(_){if(typeof _=="number"){if(this.pos+_>this.len)throw l(this,_);this.pos+=_}else do if(this.pos>=this.len)throw l(this);while(128&this.buf[this.pos++]);return this},c.prototype.skipType=function(_){switch(_){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(_=7&this.uint32())!=4;)this.skipType(_);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+_+" at offset "+this.pos)}return this},c._configure=function(_){t=_,c.create=u(),t._configure();var m=r.Long?"toLong":"toNumber";r.merge(c.prototype,{int64:function(){return i.call(this)[m](!1)},uint64:function(){return i.call(this)[m](!0)},sint64:function(){return i.call(this).zzDecode()[m](!1)},fixed64:function(){return p.call(this)[m](!0)},sfixed64:function(){return p.call(this)[m](!1)}})}},593:(a,e,n)=>{a.exports=o;var t=n(1408);(o.prototype=Object.create(t.prototype)).constructor=o;var r=n(9693);function o(s){t.call(this,s)}o._configure=function(){r.Buffer&&(o.prototype._slice=r.Buffer.prototype.slice)},o.prototype.string=function(){var s=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+s,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+s,this.len))},o._configure()},5054:a=>{a.exports={}},5994:(a,e,n)=>{e.Service=n(7948)},7948:(a,e,n)=>{a.exports=r;var t=n(9693);function r(o,s,l){if(typeof o!="function")throw TypeError("rpcImpl must be a function");t.EventEmitter.call(this),this.rpcImpl=o,this.requestDelimited=!!s,this.responseDelimited=!!l}(r.prototype=Object.create(t.EventEmitter.prototype)).constructor=r,r.prototype.rpcCall=function o(s,l,c,f,h){if(!f)throw TypeError("request must be specified");var u=this;if(!h)return t.asPromise(o,u,s,l,c,f);if(u.rpcImpl)try{return u.rpcImpl(s,l[u.requestDelimited?"encodeDelimited":"encode"](f).finish(),function(i,d){if(i)return u.emit("error",i,s),h(i);if(d!==null){if(!(d instanceof c))try{d=c[u.responseDelimited?"decodeDelimited":"decode"](d)}catch(p){return u.emit("error",p,s),h(p)}return u.emit("data",d,s),h(null,d)}u.end(!0)})}catch(i){return u.emit("error",i,s),void setTimeout(function(){h(i)},0)}else setTimeout(function(){h(Error("already ended"))},0)},r.prototype.end=function(o){return this.rpcImpl&&(o||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},1945:(a,e,n)=>{a.exports=r;var t=n(9693);function r(c,f){this.lo=c>>>0,this.hi=f>>>0}var o=r.zero=new r(0,0);o.toNumber=function(){return 0},o.zzEncode=o.zzDecode=function(){return this},o.length=function(){return 1};var s=r.zeroHash="\0\0\0\0\0\0\0\0";r.fromNumber=function(c){if(c===0)return o;var f=c<0;f&&(c=-c);var h=c>>>0,u=(c-h)/4294967296>>>0;return f&&(u=~u>>>0,h=~h>>>0,++h>4294967295&&(h=0,++u>4294967295&&(u=0))),new r(h,u)},r.from=function(c){if(typeof c=="number")return r.fromNumber(c);if(t.isString(c)){if(!t.Long)return r.fromNumber(parseInt(c,10));c=t.Long.fromString(c)}return c.low||c.high?new r(c.low>>>0,c.high>>>0):o},r.prototype.toNumber=function(c){if(!c&&this.hi>>>31){var f=1+~this.lo>>>0,h=~this.hi>>>0;return f||(h=h+1>>>0),-(f+4294967296*h)}return this.lo+4294967296*this.hi},r.prototype.toLong=function(c){return t.Long?new t.Long(0|this.lo,0|this.hi,!!c):{low:0|this.lo,high:0|this.hi,unsigned:!!c}};var l=String.prototype.charCodeAt;r.fromHash=function(c){return c===s?o:new r((l.call(c,0)|l.call(c,1)<<8|l.call(c,2)<<16|l.call(c,3)<<24)>>>0,(l.call(c,4)|l.call(c,5)<<8|l.call(c,6)<<16|l.call(c,7)<<24)>>>0)},r.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},r.prototype.zzEncode=function(){var c=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^c)>>>0,this.lo=(this.lo<<1^c)>>>0,this},r.prototype.zzDecode=function(){var c=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^c)>>>0,this.hi=(this.hi>>>1^c)>>>0,this},r.prototype.length=function(){var c=this.lo,f=(this.lo>>>28|this.hi<<4)>>>0,h=this.hi>>>24;return h===0?f===0?c<16384?c<128?1:2:c<2097152?3:4:f<16384?f<128?5:6:f<2097152?7:8:h<128?9:10}},9693:function(a,e,n){var t=e;function r(s,l,c){for(var f=Object.keys(l),h=0;h<f.length;++h)s[f[h]]!==void 0&&c||(s[f[h]]=l[f[h]]);return s}function o(s){function l(c,f){if(!(this instanceof l))return new l(c,f);Object.defineProperty(this,"message",{get:function(){return c}}),Error.captureStackTrace?Error.captureStackTrace(this,l):Object.defineProperty(this,"stack",{value:new Error().stack||""}),f&&r(this,f)}return l.prototype=Object.create(Error.prototype,{constructor:{value:l,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return s},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),l}t.asPromise=n(4537),t.base64=n(7419),t.EventEmitter=n(9211),t.float=n(945),t.inquire=n(7199),t.utf8=n(4997),t.pool=n(6662),t.LongBits=n(1945),t.isNode=!!(typeof commonjsGlobal<"u"&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),t.global=t.isNode&&commonjsGlobal||typeof window<"u"&&window||typeof self<"u"&&self||this,t.emptyArray=Object.freeze?Object.freeze([]):[],t.emptyObject=Object.freeze?Object.freeze({}):{},t.isInteger=Number.isInteger||function(s){return typeof s=="number"&&isFinite(s)&&Math.floor(s)===s},t.isString=function(s){return typeof s=="string"||s instanceof String},t.isObject=function(s){return s&&typeof s=="object"},t.isset=t.isSet=function(s,l){var c=s[l];return!(c==null||!s.hasOwnProperty(l))&&(typeof c!="object"||(Array.isArray(c)?c.length:Object.keys(c).length)>0)},t.Buffer=function(){try{var s=t.inquire("buffer").Buffer;return s.prototype.utf8Write?s:null}catch{return null}}(),t._Buffer_from=null,t._Buffer_allocUnsafe=null,t.newBuffer=function(s){return typeof s=="number"?t.Buffer?t._Buffer_allocUnsafe(s):new t.Array(s):t.Buffer?t._Buffer_from(s):typeof Uint8Array>"u"?s:new Uint8Array(s)},t.Array=typeof Uint8Array<"u"?Uint8Array:Array,t.Long=t.global.dcodeIO&&t.global.dcodeIO.Long||t.global.Long||t.inquire("long"),t.key2Re=/^true|false|0|1$/,t.key32Re=/^-?(?:0|[1-9][0-9]*)$/,t.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,t.longToHash=function(s){return s?t.LongBits.from(s).toHash():t.LongBits.zeroHash},t.longFromHash=function(s,l){var c=t.LongBits.fromHash(s);return t.Long?t.Long.fromBits(c.lo,c.hi,l):c.toNumber(!!l)},t.merge=r,t.lcFirst=function(s){return s.charAt(0).toLowerCase()+s.substring(1)},t.newError=o,t.ProtocolError=o("ProtocolError"),t.oneOfGetter=function(s){for(var l={},c=0;c<s.length;++c)l[s[c]]=1;return function(){for(var f=Object.keys(this),h=f.length-1;h>-1;--h)if(l[f[h]]===1&&this[f[h]]!==void 0&&this[f[h]]!==null)return f[h]}},t.oneOfSetter=function(s){return function(l){for(var c=0;c<s.length;++c)s[c]!==l&&delete this[s[c]]}},t.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},t._configure=function(){var s=t.Buffer;s?(t._Buffer_from=s.from!==Uint8Array.from&&s.from||function(l,c){return new s(l,c)},t._Buffer_allocUnsafe=s.allocUnsafe||function(l){return new s(l)}):t._Buffer_from=t._Buffer_allocUnsafe=null}},1173:(a,e,n)=>{a.exports=u;var t,r=n(9693),o=r.LongBits,s=r.base64,l=r.utf8;function c(b,v,T){this.fn=b,this.len=v,this.next=void 0,this.val=T}function f(){}function h(b){this.head=b.head,this.tail=b.tail,this.len=b.len,this.next=b.states}function u(){this.len=0,this.head=new c(f,0,0),this.tail=this.head,this.states=null}var i=function(){return r.Buffer?function(){return(u.create=function(){return new t})()}:function(){return new u}};function d(b,v,T){v[T]=255&b}function p(b,v){this.len=b,this.next=void 0,this.val=v}function _(b,v,T){for(;b.hi;)v[T++]=127&b.lo|128,b.lo=(b.lo>>>7|b.hi<<25)>>>0,b.hi>>>=7;for(;b.lo>127;)v[T++]=127&b.lo|128,b.lo=b.lo>>>7;v[T++]=b.lo}function m(b,v,T){v[T]=255&b,v[T+1]=b>>>8&255,v[T+2]=b>>>16&255,v[T+3]=b>>>24}u.create=i(),u.alloc=function(b){return new r.Array(b)},r.Array!==Array&&(u.alloc=r.pool(u.alloc,r.Array.prototype.subarray)),u.prototype._push=function(b,v,T){return this.tail=this.tail.next=new c(b,v,T),this.len+=v,this},p.prototype=Object.create(c.prototype),p.prototype.fn=function(b,v,T){for(;b>127;)v[T++]=127&b|128,b>>>=7;v[T]=b},u.prototype.uint32=function(b){return this.len+=(this.tail=this.tail.next=new p((b>>>=0)<128?1:b<16384?2:b<2097152?3:b<268435456?4:5,b)).len,this},u.prototype.int32=function(b){return b<0?this._push(_,10,o.fromNumber(b)):this.uint32(b)},u.prototype.sint32=function(b){return this.uint32((b<<1^b>>31)>>>0)},u.prototype.uint64=function(b){var v=o.from(b);return this._push(_,v.length(),v)},u.prototype.int64=u.prototype.uint64,u.prototype.sint64=function(b){var v=o.from(b).zzEncode();return this._push(_,v.length(),v)},u.prototype.bool=function(b){return this._push(d,1,b?1:0)},u.prototype.fixed32=function(b){return this._push(m,4,b>>>0)},u.prototype.sfixed32=u.prototype.fixed32,u.prototype.fixed64=function(b){var v=o.from(b);return this._push(m,4,v.lo)._push(m,4,v.hi)},u.prototype.sfixed64=u.prototype.fixed64,u.prototype.float=function(b){return this._push(r.float.writeFloatLE,4,b)},u.prototype.double=function(b){return this._push(r.float.writeDoubleLE,8,b)};var g=r.Array.prototype.set?function(b,v,T){v.set(b,T)}:function(b,v,T){for(var y=0;y<b.length;++y)v[T+y]=b[y]};u.prototype.bytes=function(b){var v=b.length>>>0;if(!v)return this._push(d,1,0);if(r.isString(b)){var T=u.alloc(v=s.length(b));s.decode(b,T,0),b=T}return this.uint32(v)._push(g,v,b)},u.prototype.string=function(b){var v=l.length(b);return v?this.uint32(v)._push(l.write,v,b):this._push(d,1,0)},u.prototype.fork=function(){return this.states=new h(this),this.head=this.tail=new c(f,0,0),this.len=0,this},u.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new c(f,0,0),this.len=0),this},u.prototype.ldelim=function(){var b=this.head,v=this.tail,T=this.len;return this.reset().uint32(T),T&&(this.tail.next=b.next,this.tail=v,this.len+=T),this},u.prototype.finish=function(){for(var b=this.head.next,v=this.constructor.alloc(this.len),T=0;b;)b.fn(b.val,v,T),T+=b.len,b=b.next;return v},u._configure=function(b){t=b,u.create=i(),t._configure()}},3155:(a,e,n)=>{a.exports=o;var t=n(1173);(o.prototype=Object.create(t.prototype)).constructor=o;var r=n(9693);function o(){t.call(this)}function s(l,c,f){l.length<40?r.utf8.write(l,c,f):c.utf8Write?c.utf8Write(l,f):c.write(l,f)}o._configure=function(){o.alloc=r._Buffer_allocUnsafe,o.writeBytesBuffer=r.Buffer&&r.Buffer.prototype instanceof Uint8Array&&r.Buffer.prototype.set.name==="set"?function(l,c,f){c.set(l,f)}:function(l,c,f){if(l.copy)l.copy(c,f,0,l.length);else for(var h=0;h<l.length;)c[f++]=l[h++]}},o.prototype.bytes=function(l){r.isString(l)&&(l=r._Buffer_from(l,"base64"));var c=l.length>>>0;return this.uint32(c),c&&this._push(o.writeBytesBuffer,c,l),this},o.prototype.string=function(l){var c=r.Buffer.byteLength(l);return this.uint32(c),c&&this._push(s,c,l),this},o._configure()},4154:a=>{a.exports=`"use strict";var e={},a="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node;if(a){var r=require("worker_threads"),t=r.parentPort;t.on("message",(e=>onmessage({data:e})));var s=require("fs");Object.assign(global,{self:global,require:require,Module:e,location:{href:__filename},Worker:r.Worker,importScripts:e=>(0,eval)(s.readFileSync(e,"utf8")+"//# sourceURL="+e),postMessage:e=>t.postMessage(e),performance:global.performance||{now:Date.now}})}var o=!1,d=function(){var e=Array.prototype.slice.call(arguments).join(" ");a?s.writeSync(2,e+"\\n"):console.error(e)};self.alert=function(){var a=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:a,threadId:e._pthread_self()})},e.instantiateWasm=(a,r)=>{var t=e.wasmModule;return e.wasmModule=null,r(new WebAssembly.Instance(t,a))},self.onunhandledrejection=e=>{throw e.reason??e},self.onmessage=function a(r){try{if("load"===r.data.cmd){let s=[];self.onmessage=e=>s.push(e),self.startWorker=r=>{e=r,postMessage({cmd:"loaded"});for(let e of s)a(e);self.onmessage=a},e.wasmModule=r.data.wasmModule;for(const a of r.data.handlers)e[a]=(...e)=>{postMessage({cmd:"callHandler",handler:a,args:e})};if(e.wasmMemory=r.data.wasmMemory,e.buffer=e.wasmMemory.buffer,e.ENVIRONMENT_IS_PTHREAD=!0,"string"==typeof r.data.urlOrBlob)importScripts(r.data.urlOrBlob);else{var t=URL.createObjectURL(r.data.urlOrBlob);importScripts(t),URL.revokeObjectURL(t)}ortWasmThreaded(e)}else if("run"===r.data.cmd){e.__emscripten_thread_init(r.data.pthread_ptr,0,0,1),e.__emscripten_thread_mailbox_await(r.data.pthread_ptr),e.establishStackSpace(),e.PThread.receiveObjectTransfer(r.data),e.PThread.threadInitTLS(),o||(o=!0);try{e.invokeEntryPoint(r.data.start_routine,r.data.arg)}catch(e){if("unwind"!=e)throw e}}else"cancel"===r.data.cmd?e._pthread_self()&&e.__emscripten_thread_exit(-1):"setimmediate"===r.data.target||("checkMailbox"===r.data.cmd?o&&e.checkMailbox():r.data.cmd&&(d("worker.js received unknown command "+r.data.cmd),d(r.data)))}catch(a){throw e.__emscripten_thread_crashed&&e.__emscripten_thread_crashed(),a}};
`},7067:()=>{},1296:()=>{},760:()=>{},1384:()=>{},3993:()=>{},908:()=>{},6953:()=>{},9925:()=>{},2806:()=>{},6449:()=>{},2850:()=>{},5381:()=>{},685:(a,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveBackend=e.registerBackend=void 0;const n={},t=[];e.registerBackend=(r,o,s)=>{if(!o||typeof o.init!="function"||typeof o.createSessionHandler!="function")throw new TypeError("not a valid backend");{const l=n[r];if(l===void 0)n[r]={backend:o,priority:s};else{if(l.priority>s)return;if(l.priority===s&&l.backend!==o)throw new Error(`cannot register backend "${r}" using priority ${s}`)}if(s>=0){const c=t.indexOf(r);c!==-1&&t.splice(c,1);for(let f=0;f<t.length;f++)if(n[t[f]].priority<=s)return void t.splice(f,0,r);t.push(r)}}},e.resolveBackend=async r=>{const o=r.length===0?t:r,s=[];for(const l of o){const c=n[l];if(c){if(c.initialized)return c.backend;if(c.aborted)continue;const f=!!c.initPromise;try{return f||(c.initPromise=c.backend.init()),await c.initPromise,c.initialized=!0,c.backend}catch(h){f||s.push({name:l,err:h}),c.aborted=!0}finally{delete c.initPromise}}}throw new Error(`no available backend found. ERR: ${s.map(l=>`[${l.name}] ${l.err}`).join(", ")}`)}},4798:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.registerBackend=void 0;var t=n(685);Object.defineProperty(e,"registerBackend",{enumerable:!0,get:function(){return t.registerBackend}})},3121:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.env=void 0;const t=n(9104);let r="warning";e.env={wasm:{},webgl:{},webgpu:{},versions:{common:t.version},set logLevel(o){if(o!==void 0){if(typeof o!="string"||["verbose","info","warning","error","fatal"].indexOf(o)===-1)throw new Error(`Unsupported logging level: ${o}`);r=o}},get logLevel(){return r}},Object.defineProperty(e.env,"logLevel",{enumerable:!0})},2457:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.env=void 0;const t=n(3121);e.env=t.env},2235:function(a,e,n){var t=this&&this.__createBinding||(Object.create?function(o,s,l,c){c===void 0&&(c=l);var f=Object.getOwnPropertyDescriptor(s,l);f&&!("get"in f?!s.__esModule:f.writable||f.configurable)||(f={enumerable:!0,get:function(){return s[l]}}),Object.defineProperty(o,c,f)}:function(o,s,l,c){c===void 0&&(c=l),o[c]=s[l]}),r=this&&this.__exportStar||function(o,s){for(var l in o)l==="default"||Object.prototype.hasOwnProperty.call(s,l)||t(s,o,l)};Object.defineProperty(e,"__esModule",{value:!0}),r(n(4798),e),r(n(2457),e),r(n(3974),e),r(n(963),e),r(n(7852),e)},8036:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.InferenceSession=void 0;const t=n(685),r=n(963);class o{constructor(l){this.handler=l}async run(l,c,f){const h={};let u={};if(typeof l!="object"||l===null||l instanceof r.Tensor||Array.isArray(l))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let i=!0;if(typeof c=="object"){if(c===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(c instanceof r.Tensor)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(c)){if(c.length===0)throw new TypeError("'fetches' cannot be an empty array.");i=!1;for(const _ of c){if(typeof _!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(_)===-1)throw new RangeError(`'fetches' contains invalid output name: ${_}.`);h[_]=null}if(typeof f=="object"&&f!==null)u=f;else if(f!==void 0)throw new TypeError("'options' must be an object.")}else{let _=!1;const m=Object.getOwnPropertyNames(c);for(const g of this.outputNames)if(m.indexOf(g)!==-1){const b=c[g];(b===null||b instanceof r.Tensor)&&(_=!0,i=!1,h[g]=b)}if(_){if(typeof f=="object"&&f!==null)u=f;else if(f!==void 0)throw new TypeError("'options' must be an object.")}else u=c}}else if(c!==void 0)throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(const _ of this.inputNames)if(l[_]===void 0)throw new Error(`input '${_}' is missing in 'feeds'.`);if(i)for(const _ of this.outputNames)h[_]=null;const d=await this.handler.run(l,h,u),p={};for(const _ in d)Object.hasOwnProperty.call(d,_)&&(p[_]=new r.Tensor(d[_].type,d[_].data,d[_].dims));return p}async release(){return this.handler.dispose()}static async create(l,c,f,h){let u,i={};if(typeof l=="string"){if(u=l,typeof c=="object"&&c!==null)i=c;else if(c!==void 0)throw new TypeError("'options' must be an object.")}else if(l instanceof Uint8Array){if(u=l,typeof c=="object"&&c!==null)i=c;else if(c!==void 0)throw new TypeError("'options' must be an object.")}else{if(!(l instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&l instanceof SharedArrayBuffer))throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");{const m=l;let g=0,b=l.byteLength;if(typeof c=="object"&&c!==null)i=c;else if(typeof c=="number"){if(g=c,!Number.isSafeInteger(g))throw new RangeError("'byteOffset' must be an integer.");if(g<0||g>=m.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${m.byteLength}).`);if(b=l.byteLength-g,typeof f=="number"){if(b=f,!Number.isSafeInteger(b))throw new RangeError("'byteLength' must be an integer.");if(b<=0||g+b>m.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${m.byteLength-g}].`);if(typeof h=="object"&&h!==null)i=h;else if(h!==void 0)throw new TypeError("'options' must be an object.")}else if(f!==void 0)throw new TypeError("'byteLength' must be a number.")}else if(c!==void 0)throw new TypeError("'options' must be an object.");u=new Uint8Array(m,g,b)}}const d=(i.executionProviders||[]).map(m=>typeof m=="string"?m:m.name),p=await(0,t.resolveBackend)(d),_=await p.createSessionHandler(u,i);return new o(_)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}e.InferenceSession=o},3974:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.InferenceSession=void 0;const t=n(8036);e.InferenceSession=t.InferenceSession},7852:(a,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},2350:(a,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tensorToImageData=e.tensorToDataURL=void 0,e.tensorToDataURL=(n,t)=>{const r=document.createElement("canvas");r.width=n.dims[3],r.height=n.dims[2];const o=r.getContext("2d");if(o!=null){let s,l;(t==null?void 0:t.tensorLayout)!==void 0&&t.tensorLayout==="NHWC"?(s=n.dims[2],l=n.dims[3]):(s=n.dims[3],l=n.dims[2]);const c=(t==null?void 0:t.format)!==void 0?t.format:"RGB",f=t==null?void 0:t.norm;let h,u;f===void 0||f.mean===void 0?h=[255,255,255,255]:typeof f.mean=="number"?h=[f.mean,f.mean,f.mean,f.mean]:(h=[f.mean[0],f.mean[1],f.mean[2],0],f.mean[3]!==void 0&&(h[3]=f.mean[3])),f===void 0||f.bias===void 0?u=[0,0,0,0]:typeof f.bias=="number"?u=[f.bias,f.bias,f.bias,f.bias]:(u=[f.bias[0],f.bias[1],f.bias[2],0],f.bias[3]!==void 0&&(u[3]=f.bias[3]));const i=l*s;let d=0,p=i,_=2*i,m=-1;c==="RGBA"?(d=0,p=i,_=2*i,m=3*i):c==="RGB"?(d=0,p=i,_=2*i):c==="RBG"&&(d=0,_=i,p=2*i);for(let g=0;g<l;g++)for(let b=0;b<s;b++){const v=(n.data[d++]-u[0])*h[0],T=(n.data[p++]-u[1])*h[1],y=(n.data[_++]-u[2])*h[2],w=m===-1?255:(n.data[m++]-u[3])*h[3];o.fillStyle="rgba("+v+","+T+","+y+","+w+")",o.fillRect(b,g,1,1)}return r.toDataURL()}throw new Error("Can not access image data")},e.tensorToImageData=(n,t)=>{const r=document.createElement("canvas").getContext("2d");let o;if(r==null)throw new Error("Can not access image data");{let s,l,c;(t==null?void 0:t.tensorLayout)!==void 0&&t.tensorLayout==="NHWC"?(s=n.dims[2],l=n.dims[1],c=n.dims[3]):(s=n.dims[3],l=n.dims[2],c=n.dims[1]);const f=t!==void 0&&t.format!==void 0?t.format:"RGB",h=t==null?void 0:t.norm;let u,i;h===void 0||h.mean===void 0?u=[255,255,255,255]:typeof h.mean=="number"?u=[h.mean,h.mean,h.mean,h.mean]:(u=[h.mean[0],h.mean[1],h.mean[2],255],h.mean[3]!==void 0&&(u[3]=h.mean[3])),h===void 0||h.bias===void 0?i=[0,0,0,0]:typeof h.bias=="number"?i=[h.bias,h.bias,h.bias,h.bias]:(i=[h.bias[0],h.bias[1],h.bias[2],0],h.bias[3]!==void 0&&(i[3]=h.bias[3]));const d=l*s;if(t!==void 0&&(t.format!==void 0&&c===4&&t.format!=="RGBA"||c===3&&t.format!=="RGB"&&t.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");const p=4;let _=0,m=1,g=2,b=3,v=0,T=d,y=2*d,w=-1;f==="RGBA"?(v=0,T=d,y=2*d,w=3*d):f==="RGB"?(v=0,T=d,y=2*d):f==="RBG"&&(v=0,y=d,T=2*d),o=r.createImageData(s,l);for(let S=0;S<l*s;_+=p,m+=p,g+=p,b+=p,S++)o.data[_]=(n.data[v++]-i[0])*u[0],o.data[m]=(n.data[T++]-i[1])*u[1],o.data[g]=(n.data[y++]-i[2])*u[2],o.data[b]=w===-1?255:(n.data[w++]-i[3])*u[3]}return o}},4866:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tensorFromImage=e.bufferToTensor=void 0;const t=n(963);e.bufferToTensor=(r,o)=>{if(r===void 0)throw new Error("Image buffer must be defined");if(o.height===void 0||o.width===void 0)throw new Error("Image height and width must be defined");if(o.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");const{height:s,width:l}=o,c=o.norm??{mean:255,bias:0};let f,h;f=typeof c.mean=="number"?[c.mean,c.mean,c.mean,c.mean]:[c.mean[0],c.mean[1],c.mean[2],c.mean[3]??255],h=typeof c.bias=="number"?[c.bias,c.bias,c.bias,c.bias]:[c.bias[0],c.bias[1],c.bias[2],c.bias[3]??0];const u=o.format!==void 0?o.format:"RGBA",i=o.tensorFormat!==void 0&&o.tensorFormat!==void 0?o.tensorFormat:"RGB",d=s*l,p=i==="RGBA"?new Float32Array(4*d):new Float32Array(3*d);let _=4,m=0,g=1,b=2,v=3,T=0,y=d,w=2*d,S=-1;u==="RGB"&&(_=3,m=0,g=1,b=2,v=-1),i==="RGBA"?S=3*d:i==="RBG"?(T=0,w=d,y=2*d):i==="BGR"&&(w=0,y=d,T=2*d);for(let O=0;O<d;O++,m+=_,b+=_,g+=_,v+=_)p[T++]=(r[m]+h[0])/f[0],p[y++]=(r[g]+h[1])/f[1],p[w++]=(r[b]+h[2])/f[2],S!==-1&&v!==-1&&(p[S++]=(r[v]+h[3])/f[3]);return i==="RGBA"?new t.Tensor("float32",p,[1,4,s,l]):new t.Tensor("float32",p,[1,3,s,l])},e.tensorFromImage=async(r,o)=>{const s=typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement,l=typeof ImageData<"u"&&r instanceof ImageData,c=typeof ImageBitmap<"u"&&r instanceof ImageBitmap,f=typeof r=="string";let h,u=o??{};if(s){const i=document.createElement("canvas");i.width=r.width,i.height=r.height;const d=i.getContext("2d");if(d==null)throw new Error("Can not access image data");{let p=r.height,_=r.width;if(o!==void 0&&o.resizedHeight!==void 0&&o.resizedWidth!==void 0&&(p=o.resizedHeight,_=o.resizedWidth),o!==void 0){if(u=o,o.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");u.tensorFormat="RGBA",u.height=p,u.width=_}else u.tensorFormat="RGBA",u.height=p,u.width=_;d.drawImage(r,0,0),h=d.getImageData(0,0,_,p).data}}else{if(!l){if(c){if(o===void 0)throw new Error("Please provide image config with format for Imagebitmap");const i=document.createElement("canvas");i.width=r.width,i.height=r.height;const d=i.getContext("2d");if(d!=null){const p=r.height,_=r.width;return d.drawImage(r,0,0,_,p),h=d.getImageData(0,0,_,p).data,u.height=p,u.width=_,(0,e.bufferToTensor)(h,u)}throw new Error("Can not access image data")}if(f)return new Promise((i,d)=>{const p=document.createElement("canvas"),_=p.getContext("2d");if(!r||!_)return d();const m=new Image;m.crossOrigin="Anonymous",m.src=r,m.onload=()=>{p.width=m.width,p.height=m.height,_.drawImage(m,0,0,p.width,p.height);const g=_.getImageData(0,0,p.width,p.height);u.height=p.height,u.width=p.width,i((0,e.bufferToTensor)(g.data,u))}});throw new Error("Input data provided is not supported - aborted tensor creation")}{let i,d;if(o!==void 0&&o.resizedWidth!==void 0&&o.resizedHeight!==void 0?(i=o.resizedHeight,d=o.resizedWidth):(i=r.height,d=r.width),o!==void 0&&(u=o),u.format="RGBA",u.height=i,u.width=d,o!==void 0){const p=document.createElement("canvas");p.width=d,p.height=i;const _=p.getContext("2d");if(_==null)throw new Error("Can not access image data");_.putImageData(r,0,0),h=_.getImageData(0,0,d,i).data}else h=r.data}}if(h!==void 0)return(0,e.bufferToTensor)(h,u);throw new Error("Input data provided is not supported - aborted tensor creation")}},5957:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Tensor=void 0;const t=n(2350),r=n(4866),o=n(106),s=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["float16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),l=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]);let c=!1;e.Tensor=class{constructor(f,h,u){let i,d,p;if((()=>{if(!c){c=!0;const m=typeof BigInt64Array<"u"&&typeof BigInt64Array.from=="function",g=typeof BigUint64Array<"u"&&typeof BigUint64Array.from=="function";m&&(s.set("int64",BigInt64Array),l.set(BigInt64Array,"int64")),g&&(s.set("uint64",BigUint64Array),l.set(BigUint64Array,"uint64"))}})(),typeof f=="string")if(i=f,p=u,f==="string"){if(!Array.isArray(h))throw new TypeError("A string tensor's data must be a string array.");d=h}else{const m=s.get(f);if(m===void 0)throw new TypeError(`Unsupported tensor type: ${f}.`);if(Array.isArray(h)){if(f==="float16")throw new TypeError("Creating a float16 tensor from number array is not supported. Please use Uint16Array as data.");d=f==="uint64"||f==="int64"?m.from(h,BigInt):m.from(h)}else{if(!(h instanceof m))throw new TypeError(`A ${i} tensor's data must be type of ${m}`);d=h}}else if(p=h,Array.isArray(f)){if(f.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");const m=typeof f[0];if(m==="string")i="string",d=f;else{if(m!=="boolean")throw new TypeError(`Invalid element type of data array: ${m}.`);i="bool",d=Uint8Array.from(f)}}else{const m=l.get(f.constructor);if(m===void 0)throw new TypeError(`Unsupported type for tensor data: ${f.constructor}.`);i=m,d=f}if(p===void 0)p=[d.length];else if(!Array.isArray(p))throw new TypeError("A tensor's dims must be a number array");const _=(0,o.calculateSize)(p);if(_!==d.length)throw new Error(`Tensor's size(${_}) does not match data length(${d.length}).`);this.dims=p,this.type=i,this.data=d,this.size=_}static async fromImage(f,h){return(0,r.tensorFromImage)(f,h)}toDataURL(f){return(0,t.tensorToDataURL)(this,f)}toImageData(f){return(0,t.tensorToImageData)(this,f)}reshape(f){return(0,o.tensorReshape)(this,f)}}},106:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tensorReshape=e.calculateSize=void 0;const t=n(963);e.calculateSize=r=>{let o=1;for(let s=0;s<r.length;s++){const l=r[s];if(typeof l!="number"||!Number.isSafeInteger(l))throw new TypeError(`dims[${s}] must be an integer, got: ${l}`);if(l<0)throw new RangeError(`dims[${s}] must be a non-negative integer, got: ${l}`);o*=l}return o},e.tensorReshape=(r,o)=>new t.Tensor(r.type,r.data,o)},963:(a,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Tensor=void 0;const t=n(5957);e.Tensor=t.Tensor},9104:(a,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.version=void 0,e.version="1.16.3"},1583:(a,e)=>{var n,t=function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var o=null;try{o=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function s(I,C,L){this.low=0|I,this.high=0|C,this.unsigned=!!L}function l(I){return(I&&I.__isLong__)===!0}function c(I){var C=Math.clz32(I&-I);return I?31-C:C}s.prototype.__isLong__,Object.defineProperty(s.prototype,"__isLong__",{value:!0}),s.isLong=l;var f={},h={};function u(I,C){var L,K,G;return C?(G=0<=(I>>>=0)&&I<256)&&(K=h[I])?K:(L=d(I,0,!0),G&&(h[I]=L),L):(G=-128<=(I|=0)&&I<128)&&(K=f[I])?K:(L=d(I,I<0?-1:0,!1),G&&(f[I]=L),L)}function i(I,C){if(isNaN(I))return C?w:y;if(C){if(I<0)return w;if(I>=b)return A}else{if(I<=-v)return $;if(I+1>=v)return E}return I<0?i(-I,C).neg():d(I%g|0,I/g|0,C)}function d(I,C,L){return new s(I,C,L)}s.fromInt=u,s.fromNumber=i,s.fromBits=d;var p=Math.pow;function _(I,C,L){if(I.length===0)throw Error("empty string");if(typeof C=="number"?(L=C,C=!1):C=!!C,I==="NaN"||I==="Infinity"||I==="+Infinity"||I==="-Infinity")return C?w:y;if((L=L||10)<2||36<L)throw RangeError("radix");var K;if((K=I.indexOf("-"))>0)throw Error("interior hyphen");if(K===0)return _(I.substring(1),C,L).neg();for(var G=i(p(L,8)),J=y,Y=0;Y<I.length;Y+=8){var te=Math.min(8,I.length-Y),ee=parseInt(I.substring(Y,Y+te),L);if(te<8){var ie=i(p(L,te));J=J.mul(ie).add(i(ee))}else J=(J=J.mul(G)).add(i(ee))}return J.unsigned=C,J}function m(I,C){return typeof I=="number"?i(I,C):typeof I=="string"?_(I,C):d(I.low,I.high,typeof C=="boolean"?C:I.unsigned)}s.fromString=_,s.fromValue=m;var g=4294967296,b=g*g,v=b/2,T=u(1<<24),y=u(0);s.ZERO=y;var w=u(0,!0);s.UZERO=w;var S=u(1);s.ONE=S;var O=u(1,!0);s.UONE=O;var P=u(-1);s.NEG_ONE=P;var E=d(-1,2147483647,!1);s.MAX_VALUE=E;var A=d(-1,-1,!0);s.MAX_UNSIGNED_VALUE=A;var $=d(0,-2147483648,!1);s.MIN_VALUE=$;var k=s.prototype;k.toInt=function(){return this.unsigned?this.low>>>0:this.low},k.toNumber=function(){return this.unsigned?(this.high>>>0)*g+(this.low>>>0):this.high*g+(this.low>>>0)},k.toString=function(I){if((I=I||10)<2||36<I)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq($)){var C=i(I),L=this.div(C),K=L.mul(C).sub(this);return L.toString(I)+K.toInt().toString(I)}return"-"+this.neg().toString(I)}for(var G=i(p(I,6),this.unsigned),J=this,Y="";;){var te=J.div(G),ee=(J.sub(te.mul(G)).toInt()>>>0).toString(I);if((J=te).isZero())return ee+Y;for(;ee.length<6;)ee="0"+ee;Y=""+ee+Y}},k.getHighBits=function(){return this.high},k.getHighBitsUnsigned=function(){return this.high>>>0},k.getLowBits=function(){return this.low},k.getLowBitsUnsigned=function(){return this.low>>>0},k.getNumBitsAbs=function(){if(this.isNegative())return this.eq($)?64:this.neg().getNumBitsAbs();for(var I=this.high!=0?this.high:this.low,C=31;C>0&&!(I&1<<C);C--);return this.high!=0?C+33:C+1},k.isZero=function(){return this.high===0&&this.low===0},k.eqz=k.isZero,k.isNegative=function(){return!this.unsigned&&this.high<0},k.isPositive=function(){return this.unsigned||this.high>=0},k.isOdd=function(){return(1&this.low)==1},k.isEven=function(){return(1&this.low)==0},k.equals=function(I){return l(I)||(I=m(I)),(this.unsigned===I.unsigned||this.high>>>31!=1||I.high>>>31!=1)&&this.high===I.high&&this.low===I.low},k.eq=k.equals,k.notEquals=function(I){return!this.eq(I)},k.neq=k.notEquals,k.ne=k.notEquals,k.lessThan=function(I){return this.comp(I)<0},k.lt=k.lessThan,k.lessThanOrEqual=function(I){return this.comp(I)<=0},k.lte=k.lessThanOrEqual,k.le=k.lessThanOrEqual,k.greaterThan=function(I){return this.comp(I)>0},k.gt=k.greaterThan,k.greaterThanOrEqual=function(I){return this.comp(I)>=0},k.gte=k.greaterThanOrEqual,k.ge=k.greaterThanOrEqual,k.compare=function(I){if(l(I)||(I=m(I)),this.eq(I))return 0;var C=this.isNegative(),L=I.isNegative();return C&&!L?-1:!C&&L?1:this.unsigned?I.high>>>0>this.high>>>0||I.high===this.high&&I.low>>>0>this.low>>>0?-1:1:this.sub(I).isNegative()?-1:1},k.comp=k.compare,k.negate=function(){return!this.unsigned&&this.eq($)?$:this.not().add(S)},k.neg=k.negate,k.add=function(I){l(I)||(I=m(I));var C=this.high>>>16,L=65535&this.high,K=this.low>>>16,G=65535&this.low,J=I.high>>>16,Y=65535&I.high,te=I.low>>>16,ee=0,ie=0,ae=0,ue=0;return ae+=(ue+=G+(65535&I.low))>>>16,ie+=(ae+=K+te)>>>16,ee+=(ie+=L+Y)>>>16,ee+=C+J,d((ae&=65535)<<16|(ue&=65535),(ee&=65535)<<16|(ie&=65535),this.unsigned)},k.subtract=function(I){return l(I)||(I=m(I)),this.add(I.neg())},k.sub=k.subtract,k.multiply=function(I){if(this.isZero())return this;if(l(I)||(I=m(I)),o)return d(o.mul(this.low,this.high,I.low,I.high),o.get_high(),this.unsigned);if(I.isZero())return this.unsigned?w:y;if(this.eq($))return I.isOdd()?$:y;if(I.eq($))return this.isOdd()?$:y;if(this.isNegative())return I.isNegative()?this.neg().mul(I.neg()):this.neg().mul(I).neg();if(I.isNegative())return this.mul(I.neg()).neg();if(this.lt(T)&&I.lt(T))return i(this.toNumber()*I.toNumber(),this.unsigned);var C=this.high>>>16,L=65535&this.high,K=this.low>>>16,G=65535&this.low,J=I.high>>>16,Y=65535&I.high,te=I.low>>>16,ee=65535&I.low,ie=0,ae=0,ue=0,fe=0;return ue+=(fe+=G*ee)>>>16,ae+=(ue+=K*ee)>>>16,ue&=65535,ae+=(ue+=G*te)>>>16,ie+=(ae+=L*ee)>>>16,ae&=65535,ie+=(ae+=K*te)>>>16,ae&=65535,ie+=(ae+=G*Y)>>>16,ie+=C*ee+L*te+K*Y+G*J,d((ue&=65535)<<16|(fe&=65535),(ie&=65535)<<16|(ae&=65535),this.unsigned)},k.mul=k.multiply,k.divide=function(I){if(l(I)||(I=m(I)),I.isZero())throw Error("division by zero");var C,L,K;if(o)return this.unsigned||this.high!==-2147483648||I.low!==-1||I.high!==-1?d((this.unsigned?o.div_u:o.div_s)(this.low,this.high,I.low,I.high),o.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?w:y;if(this.unsigned){if(I.unsigned||(I=I.toUnsigned()),I.gt(this))return w;if(I.gt(this.shru(1)))return O;K=w}else{if(this.eq($))return I.eq(S)||I.eq(P)?$:I.eq($)?S:(C=this.shr(1).div(I).shl(1)).eq(y)?I.isNegative()?S:P:(L=this.sub(I.mul(C)),K=C.add(L.div(I)));if(I.eq($))return this.unsigned?w:y;if(this.isNegative())return I.isNegative()?this.neg().div(I.neg()):this.neg().div(I).neg();if(I.isNegative())return this.div(I.neg()).neg();K=y}for(L=this;L.gte(I);){C=Math.max(1,Math.floor(L.toNumber()/I.toNumber()));for(var G=Math.ceil(Math.log(C)/Math.LN2),J=G<=48?1:p(2,G-48),Y=i(C),te=Y.mul(I);te.isNegative()||te.gt(L);)te=(Y=i(C-=J,this.unsigned)).mul(I);Y.isZero()&&(Y=S),K=K.add(Y),L=L.sub(te)}return K},k.div=k.divide,k.modulo=function(I){return l(I)||(I=m(I)),o?d((this.unsigned?o.rem_u:o.rem_s)(this.low,this.high,I.low,I.high),o.get_high(),this.unsigned):this.sub(this.div(I).mul(I))},k.mod=k.modulo,k.rem=k.modulo,k.not=function(){return d(~this.low,~this.high,this.unsigned)},k.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},k.clz=k.countLeadingZeros,k.countTrailingZeros=function(){return this.low?c(this.low):c(this.high)+32},k.ctz=k.countTrailingZeros,k.and=function(I){return l(I)||(I=m(I)),d(this.low&I.low,this.high&I.high,this.unsigned)},k.or=function(I){return l(I)||(I=m(I)),d(this.low|I.low,this.high|I.high,this.unsigned)},k.xor=function(I){return l(I)||(I=m(I)),d(this.low^I.low,this.high^I.high,this.unsigned)},k.shiftLeft=function(I){return l(I)&&(I=I.toInt()),(I&=63)==0?this:I<32?d(this.low<<I,this.high<<I|this.low>>>32-I,this.unsigned):d(0,this.low<<I-32,this.unsigned)},k.shl=k.shiftLeft,k.shiftRight=function(I){return l(I)&&(I=I.toInt()),(I&=63)==0?this:I<32?d(this.low>>>I|this.high<<32-I,this.high>>I,this.unsigned):d(this.high>>I-32,this.high>=0?0:-1,this.unsigned)},k.shr=k.shiftRight,k.shiftRightUnsigned=function(I){return l(I)&&(I=I.toInt()),(I&=63)==0?this:I<32?d(this.low>>>I|this.high<<32-I,this.high>>>I,this.unsigned):d(I===32?this.high:this.high>>>I-32,0,this.unsigned)},k.shru=k.shiftRightUnsigned,k.shr_u=k.shiftRightUnsigned,k.rotateLeft=function(I){var C;return l(I)&&(I=I.toInt()),(I&=63)==0?this:I===32?d(this.high,this.low,this.unsigned):I<32?(C=32-I,d(this.low<<I|this.high>>>C,this.high<<I|this.low>>>C,this.unsigned)):(C=32-(I-=32),d(this.high<<I|this.low>>>C,this.low<<I|this.high>>>C,this.unsigned))},k.rotl=k.rotateLeft,k.rotateRight=function(I){var C;return l(I)&&(I=I.toInt()),(I&=63)==0?this:I===32?d(this.high,this.low,this.unsigned):I<32?(C=32-I,d(this.high<<C|this.low>>>I,this.low<<C|this.high>>>I,this.unsigned)):(C=32-(I-=32),d(this.low<<C|this.high>>>I,this.high<<C|this.low>>>I,this.unsigned))},k.rotr=k.rotateRight,k.toSigned=function(){return this.unsigned?d(this.low,this.high,!1):this},k.toUnsigned=function(){return this.unsigned?this:d(this.low,this.high,!0)},k.toBytes=function(I){return I?this.toBytesLE():this.toBytesBE()},k.toBytesLE=function(){var I=this.high,C=this.low;return[255&C,C>>>8&255,C>>>16&255,C>>>24,255&I,I>>>8&255,I>>>16&255,I>>>24]},k.toBytesBE=function(){var I=this.high,C=this.low;return[I>>>24,I>>>16&255,I>>>8&255,255&I,C>>>24,C>>>16&255,C>>>8&255,255&C]},s.fromBytes=function(I,C,L){return L?s.fromBytesLE(I,C):s.fromBytesBE(I,C)},s.fromBytesLE=function(I,C){return new s(I[0]|I[1]<<8|I[2]<<16|I[3]<<24,I[4]|I[5]<<8|I[6]<<16|I[7]<<24,C)},s.fromBytesBE=function(I,C){return new s(I[4]<<24|I[5]<<16|I[6]<<8|I[7],I[0]<<24|I[1]<<16|I[2]<<8|I[3],C)};var D=s;return r.default=D,"default"in r?r.default:r}({});(n=(function(){return t}).apply(e,[]))===void 0||(a.exports=n)},5686:(a,e,n)=>{n.r(e),n.d(e,{flatbuffers:()=>t});var t={};t.Offset,t.Table,t.SIZEOF_SHORT=2,t.SIZEOF_INT=4,t.FILE_IDENTIFIER_LENGTH=4,t.SIZE_PREFIX_LENGTH=4,t.Encoding={UTF8_BYTES:1,UTF16_STRING:2},t.int32=new Int32Array(2),t.float32=new Float32Array(t.int32.buffer),t.float64=new Float64Array(t.int32.buffer),t.isLittleEndian=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,t.Long=function(r,o){this.low=0|r,this.high=0|o},t.Long.create=function(r,o){return r==0&&o==0?t.Long.ZERO:new t.Long(r,o)},t.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},t.Long.prototype.equals=function(r){return this.low==r.low&&this.high==r.high},t.Long.ZERO=new t.Long(0,0),t.Builder=function(r){if(r)o=r;else var o=1024;this.bb=t.ByteBuffer.allocate(o),this.space=o,this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},t.Builder.prototype.clear=function(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},t.Builder.prototype.forceDefaults=function(r){this.force_defaults=r},t.Builder.prototype.dataBuffer=function(){return this.bb},t.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},t.Builder.prototype.prep=function(r,o){r>this.minalign&&(this.minalign=r);for(var s=1+~(this.bb.capacity()-this.space+o)&r-1;this.space<s+r+o;){var l=this.bb.capacity();this.bb=t.Builder.growByteBuffer(this.bb),this.space+=this.bb.capacity()-l}this.pad(s)},t.Builder.prototype.pad=function(r){for(var o=0;o<r;o++)this.bb.writeInt8(--this.space,0)},t.Builder.prototype.writeInt8=function(r){this.bb.writeInt8(this.space-=1,r)},t.Builder.prototype.writeInt16=function(r){this.bb.writeInt16(this.space-=2,r)},t.Builder.prototype.writeInt32=function(r){this.bb.writeInt32(this.space-=4,r)},t.Builder.prototype.writeInt64=function(r){this.bb.writeInt64(this.space-=8,r)},t.Builder.prototype.writeFloat32=function(r){this.bb.writeFloat32(this.space-=4,r)},t.Builder.prototype.writeFloat64=function(r){this.bb.writeFloat64(this.space-=8,r)},t.Builder.prototype.addInt8=function(r){this.prep(1,0),this.writeInt8(r)},t.Builder.prototype.addInt16=function(r){this.prep(2,0),this.writeInt16(r)},t.Builder.prototype.addInt32=function(r){this.prep(4,0),this.writeInt32(r)},t.Builder.prototype.addInt64=function(r){this.prep(8,0),this.writeInt64(r)},t.Builder.prototype.addFloat32=function(r){this.prep(4,0),this.writeFloat32(r)},t.Builder.prototype.addFloat64=function(r){this.prep(8,0),this.writeFloat64(r)},t.Builder.prototype.addFieldInt8=function(r,o,s){(this.force_defaults||o!=s)&&(this.addInt8(o),this.slot(r))},t.Builder.prototype.addFieldInt16=function(r,o,s){(this.force_defaults||o!=s)&&(this.addInt16(o),this.slot(r))},t.Builder.prototype.addFieldInt32=function(r,o,s){(this.force_defaults||o!=s)&&(this.addInt32(o),this.slot(r))},t.Builder.prototype.addFieldInt64=function(r,o,s){!this.force_defaults&&o.equals(s)||(this.addInt64(o),this.slot(r))},t.Builder.prototype.addFieldFloat32=function(r,o,s){(this.force_defaults||o!=s)&&(this.addFloat32(o),this.slot(r))},t.Builder.prototype.addFieldFloat64=function(r,o,s){(this.force_defaults||o!=s)&&(this.addFloat64(o),this.slot(r))},t.Builder.prototype.addFieldOffset=function(r,o,s){(this.force_defaults||o!=s)&&(this.addOffset(o),this.slot(r))},t.Builder.prototype.addFieldStruct=function(r,o,s){o!=s&&(this.nested(o),this.slot(r))},t.Builder.prototype.nested=function(r){if(r!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")},t.Builder.prototype.notNested=function(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")},t.Builder.prototype.slot=function(r){this.vtable[r]=this.offset()},t.Builder.prototype.offset=function(){return this.bb.capacity()-this.space},t.Builder.growByteBuffer=function(r){var o=r.capacity();if(3221225472&o)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var s=o<<1,l=t.ByteBuffer.allocate(s);return l.setPosition(s-o),l.bytes().set(r.bytes(),s-o),l},t.Builder.prototype.addOffset=function(r){this.prep(t.SIZEOF_INT,0),this.writeInt32(this.offset()-r+t.SIZEOF_INT)},t.Builder.prototype.startObject=function(r){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=r;for(var o=0;o<r;o++)this.vtable[o]=0;this.isNested=!0,this.object_start=this.offset()},t.Builder.prototype.endObject=function(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var r=this.offset(),o=this.vtable_in_use-1;o>=0&&this.vtable[o]==0;o--);for(var s=o+1;o>=0;o--)this.addInt16(this.vtable[o]!=0?r-this.vtable[o]:0);this.addInt16(r-this.object_start);var l=(s+2)*t.SIZEOF_SHORT;this.addInt16(l);var c=0,f=this.space;e:for(o=0;o<this.vtables.length;o++){var h=this.bb.capacity()-this.vtables[o];if(l==this.bb.readInt16(h)){for(var u=t.SIZEOF_SHORT;u<l;u+=t.SIZEOF_SHORT)if(this.bb.readInt16(f+u)!=this.bb.readInt16(h+u))continue e;c=this.vtables[o];break}}return c?(this.space=this.bb.capacity()-r,this.bb.writeInt32(this.space,c-r)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-r,this.offset()-r)),this.isNested=!1,r},t.Builder.prototype.finish=function(r,o,s){var l=s?t.SIZE_PREFIX_LENGTH:0;if(o){var c=o;if(this.prep(this.minalign,t.SIZEOF_INT+t.FILE_IDENTIFIER_LENGTH+l),c.length!=t.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+t.FILE_IDENTIFIER_LENGTH);for(var f=t.FILE_IDENTIFIER_LENGTH-1;f>=0;f--)this.writeInt8(c.charCodeAt(f))}this.prep(this.minalign,t.SIZEOF_INT+l),this.addOffset(r),l&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},t.Builder.prototype.finishSizePrefixed=function(r,o){this.finish(r,o,!0)},t.Builder.prototype.requiredField=function(r,o){var s=this.bb.capacity()-r,l=s-this.bb.readInt32(s);if(this.bb.readInt16(l+o)==0)throw new Error("FlatBuffers: field "+o+" must be set")},t.Builder.prototype.startVector=function(r,o,s){this.notNested(),this.vector_num_elems=o,this.prep(t.SIZEOF_INT,r*o),this.prep(s,r*o)},t.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},t.Builder.prototype.createString=function(r){if(r instanceof Uint8Array)var o=r;else{o=[];for(var s=0;s<r.length;){var l,c=r.charCodeAt(s++);(l=c<55296||c>=56320?c:(c<<10)+r.charCodeAt(s++)+-56613888)<128?o.push(l):(l<2048?o.push(l>>6&31|192):(l<65536?o.push(l>>12&15|224):o.push(l>>18&7|240,l>>12&63|128),o.push(l>>6&63|128)),o.push(63&l|128))}}this.addInt8(0),this.startVector(1,o.length,1),this.bb.setPosition(this.space-=o.length),s=0;for(var f=this.space,h=this.bb.bytes();s<o.length;s++)h[f++]=o[s];return this.endVector()},t.Builder.prototype.createLong=function(r,o){return t.Long.create(r,o)},t.ByteBuffer=function(r){this.bytes_=r,this.position_=0},t.ByteBuffer.allocate=function(r){return new t.ByteBuffer(new Uint8Array(r))},t.ByteBuffer.prototype.clear=function(){this.position_=0},t.ByteBuffer.prototype.bytes=function(){return this.bytes_},t.ByteBuffer.prototype.position=function(){return this.position_},t.ByteBuffer.prototype.setPosition=function(r){this.position_=r},t.ByteBuffer.prototype.capacity=function(){return this.bytes_.length},t.ByteBuffer.prototype.readInt8=function(r){return this.readUint8(r)<<24>>24},t.ByteBuffer.prototype.readUint8=function(r){return this.bytes_[r]},t.ByteBuffer.prototype.readInt16=function(r){return this.readUint16(r)<<16>>16},t.ByteBuffer.prototype.readUint16=function(r){return this.bytes_[r]|this.bytes_[r+1]<<8},t.ByteBuffer.prototype.readInt32=function(r){return this.bytes_[r]|this.bytes_[r+1]<<8|this.bytes_[r+2]<<16|this.bytes_[r+3]<<24},t.ByteBuffer.prototype.readUint32=function(r){return this.readInt32(r)>>>0},t.ByteBuffer.prototype.readInt64=function(r){return new t.Long(this.readInt32(r),this.readInt32(r+4))},t.ByteBuffer.prototype.readUint64=function(r){return new t.Long(this.readUint32(r),this.readUint32(r+4))},t.ByteBuffer.prototype.readFloat32=function(r){return t.int32[0]=this.readInt32(r),t.float32[0]},t.ByteBuffer.prototype.readFloat64=function(r){return t.int32[t.isLittleEndian?0:1]=this.readInt32(r),t.int32[t.isLittleEndian?1:0]=this.readInt32(r+4),t.float64[0]},t.ByteBuffer.prototype.writeInt8=function(r,o){this.bytes_[r]=o},t.ByteBuffer.prototype.writeUint8=function(r,o){this.bytes_[r]=o},t.ByteBuffer.prototype.writeInt16=function(r,o){this.bytes_[r]=o,this.bytes_[r+1]=o>>8},t.ByteBuffer.prototype.writeUint16=function(r,o){this.bytes_[r]=o,this.bytes_[r+1]=o>>8},t.ByteBuffer.prototype.writeInt32=function(r,o){this.bytes_[r]=o,this.bytes_[r+1]=o>>8,this.bytes_[r+2]=o>>16,this.bytes_[r+3]=o>>24},t.ByteBuffer.prototype.writeUint32=function(r,o){this.bytes_[r]=o,this.bytes_[r+1]=o>>8,this.bytes_[r+2]=o>>16,this.bytes_[r+3]=o>>24},t.ByteBuffer.prototype.writeInt64=function(r,o){this.writeInt32(r,o.low),this.writeInt32(r+4,o.high)},t.ByteBuffer.prototype.writeUint64=function(r,o){this.writeUint32(r,o.low),this.writeUint32(r+4,o.high)},t.ByteBuffer.prototype.writeFloat32=function(r,o){t.float32[0]=o,this.writeInt32(r,t.int32[0])},t.ByteBuffer.prototype.writeFloat64=function(r,o){t.float64[0]=o,this.writeInt32(r,t.int32[t.isLittleEndian?0:1]),this.writeInt32(r+4,t.int32[t.isLittleEndian?1:0])},t.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+t.SIZEOF_INT+t.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var r="",o=0;o<t.FILE_IDENTIFIER_LENGTH;o++)r+=String.fromCharCode(this.readInt8(this.position_+t.SIZEOF_INT+o));return r},t.ByteBuffer.prototype.__offset=function(r,o){var s=r-this.readInt32(r);return o<this.readInt16(s)?this.readInt16(s+o):0},t.ByteBuffer.prototype.__union=function(r,o){return r.bb_pos=o+this.readInt32(o),r.bb=this,r},t.ByteBuffer.prototype.__string=function(r,o){r+=this.readInt32(r);var s=this.readInt32(r),l="",c=0;if(r+=t.SIZEOF_INT,o===t.Encoding.UTF8_BYTES)return this.bytes_.subarray(r,r+s);for(;c<s;){var f,h=this.readUint8(r+c++);if(h<192)f=h;else{var u=this.readUint8(r+c++);if(h<224)f=(31&h)<<6|63&u;else{var i=this.readUint8(r+c++);f=h<240?(15&h)<<12|(63&u)<<6|63&i:(7&h)<<18|(63&u)<<12|(63&i)<<6|63&this.readUint8(r+c++)}}f<65536?l+=String.fromCharCode(f):(f-=65536,l+=String.fromCharCode(55296+(f>>10),56320+(1023&f)))}return l},t.ByteBuffer.prototype.__indirect=function(r){return r+this.readInt32(r)},t.ByteBuffer.prototype.__vector=function(r){return r+this.readInt32(r)+t.SIZEOF_INT},t.ByteBuffer.prototype.__vector_len=function(r){return this.readInt32(r+this.readInt32(r))},t.ByteBuffer.prototype.__has_identifier=function(r){if(r.length!=t.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+t.FILE_IDENTIFIER_LENGTH);for(var o=0;o<t.FILE_IDENTIFIER_LENGTH;o++)if(r.charCodeAt(o)!=this.readInt8(this.position_+t.SIZEOF_INT+o))return!1;return!0},t.ByteBuffer.prototype.createLong=function(r,o){return t.Long.create(r,o)}}},__webpack_module_cache__={};function __webpack_require__(a){var e=__webpack_module_cache__[a];if(e!==void 0)return e.exports;var n=__webpack_module_cache__[a]={exports:{}};return __webpack_modules__[a].call(n.exports,n,n.exports,__webpack_require__),n.exports}__webpack_require__.n=a=>{var e=a&&a.__esModule?()=>a.default:()=>a;return __webpack_require__.d(e,{a:e}),e},__webpack_require__.d=(a,e)=>{for(var n in e)__webpack_require__.o(e,n)&&!__webpack_require__.o(a,n)&&Object.defineProperty(a,n,{enumerable:!0,get:e[n]})},__webpack_require__.o=(a,e)=>Object.prototype.hasOwnProperty.call(a,e),__webpack_require__.r=a=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(1057);return __webpack_exports__})())})(ort_min);var ort_minExports=ort_min.exports;/**
 * @copyright CEA
 * @author CEA
 * @license CECILL
 *
 * This software is a collaborative computer program whose purpose is to
 * generate and explore labeled data for computer vision applications.
 * This software is governed by the CeCILL-C license under French law and
 * abiding by the rules of distribution of free software. You can use,
 * modify and/ or redistribute the software under the terms of the CeCILL-C
 * license as circulated by CEA, CNRS and INRIA at the following URL
 *
 * http://www.cecill.info
 */ort_minExports.env.wasm.wasmPaths="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.16.1/dist/";class SAM{constructor(){nt(this,"onnxModel");nt(this,"previousMask",null);nt(this,"imageLongSideLength",1024);nt(this,"predictionThreshold",0)}async init(e){this.onnxModel=await ort_minExports.InferenceSession.create(e)}getScalingFactor(e,n){return this.imageLongSideLength/Math.max(e,n)}getPreviousMask(){let e,n;return this.previousMask?(e=this.previousMask,n=new ort_minExports.Tensor("float32",[1])):(e=new ort_minExports.Tensor("float32",new Float32Array(256*256),[1,1,256,256]),n=new ort_minExports.Tensor("float32",[0])),[e,n]}preProcessInputs(e,n,t,r){const o=this.getScalingFactor(t,r),s=e==null?void 0:e.length,l=n?2:1,c=new Float32Array(2*(s+l)),f=new Float32Array(s+l);for(let i=0;i<s;i++)c[2*i]=e[i].x*o,c[2*i+1]=e[i].y*o,f[i]=e[i].label;n?(c[2*s]=Math.min(n.x,n.x+n.width)*o,c[2*s+1]=Math.min(n.y,n.y+n.height)*o,f[s]=2,c[2*s+2]=Math.max(n.x,n.x+n.width)*o,c[2*s+3]=Math.max(n.y,n.y+n.height)*o,f[s+1]=3):(c[2*s]=0,c[2*s+1]=0,f[s]=-1);const h=new ort_minExports.Tensor("float32",c,[1,s+l,2]),u=new ort_minExports.Tensor("float32",f,[1,s+l]);return{points:h,labels:u}}async segmentImage(e){const n=e.image.naturalWidth,t=e.image.naturalHeight,r=new ort_minExports.Tensor("float32",[t,n]),o=this.preProcessInputs(e.points,e.box,n,t),s=this.getPreviousMask(),l={image_embeddings:e.embedding,point_coords:o.points,point_labels:o.labels,orig_im_size:r,mask_input:s[0],has_mask_input:s[1]},c=Date.now(),f=await this.onnxModel.run(l);console.log("SAM.segmentImage in",Date.now()-c,"ms"),this.previousMask=f.low_res_masks;const h=maskDataToFortranArrayToRle(f.masks.data,t,n),u=generatePolygonSegments(h,t);return{masksImageSVG:convertSegmentsToSVG(u),rle:{counts:h,size:[t,n]},masks:f.mask}}inputNames(){return this.onnxModel.inputNames}outputNames(){return this.onnxModel.outputNames}reset(){this.previousMask=null}}const GROUND_TRUTH="Ground Truth",PRE_ANNOTATION="Pre-annotation",EXISTING_SOURCE_IDS=[GROUND_TRUTH,PRE_ANNOTATION],HIGHLIGHTED_BOX_STROKE_FACTOR=4,HIGHLIGHTED_MASK_STROKE_FACTOR=2,NOT_ANNOTATION_ITEM_OPACITY=.3,DEFAULT_FEATURE="category",defaultObjectFeatures={[DEFAULT_FEATURE]:{name:"category",dtype:"str",label:"category"}},defaultSceneFeatures={label:{name:"label",dtype:"str",value:"None"}},urlAlphabet="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let nanoid=(a=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(a));for(;a--;)e+=urlAlphabet[n[a]&63];return e};const defineTooltip=a=>{var t,r;if(!a.bbox)return null;const e=a.bbox.confidence!=0&&a.source_id!==GROUND_TRUTH?" "+a.bbox.confidence.toFixed(2):"";return typeof((t=a.features[DEFAULT_FEATURE])==null?void 0:t.value)=="string"?((r=a.features[DEFAULT_FEATURE])==null?void 0:r.value)+e:null},mapObjectToBBox=(a,e)=>{var d,p,_,m;const n=a.datasetItemType==="video"?a.displayedBox:a.bbox;if(!n||a.datasetItemType==="video"&&a.displayedBox.hidden||a.source_id===PRE_ANNOTATION&&a.highlighted!=="self")return;const t=e==null?void 0:e[a.view_id],r=Array.isArray(t)?t[0]:t,o=r.features.height.value||1,s=r.features.width.value||1,[l,c,f,h]=n.coords,u=[l*s,c*o,f*s,h*o],i=defineTooltip(a);return{id:a.id,viewId:a.view_id,catId:((d=a.features.category_id)==null?void 0:d.value)||1,bbox:u,tooltip:i,opacity:a.highlighted==="none"?NOT_ANNOTATION_ITEM_OPACITY:1,visible:!((p=n.displayControl)!=null&&p.hidden)&&!((_=a.displayControl)!=null&&_.hidden),editing:(m=a.displayControl)==null?void 0:m.editing,strokeFactor:a.highlighted==="self"?HIGHLIGHTED_BOX_STROKE_FACTOR:1,highlighted:a.highlighted}},mapObjectToMasks=a=>{var o,s,l,c;if(!a.mask||a.review_state||a.source_id===PRE_ANNOTATION&&a.review_state==="accepted")return;const e=a.mask.counts,n=a.mask.size,t=generatePolygonSegments(e,n[0]),r=convertSegmentsToSVG(t);return{id:a.id,viewId:a.view_id,svg:r,rle:a.mask,catId:((o=a.features.category_id)==null?void 0:o.value)||1,visible:!((s=a.mask.displayControl)!=null&&s.hidden)&&!((l=a.displayControl)!=null&&l.hidden),editing:(c=a.displayControl)==null?void 0:c.editing,opacity:a.highlighted==="none"?NOT_ANNOTATION_ITEM_OPACITY:1,strokeFactor:a.highlighted==="self"?HIGHLIGHTED_MASK_STROKE_FACTOR:1,highlighted:a.highlighted}},toggleObjectDisplayControl=(a,e,n,t)=>(n.includes("bbox")&&a.bbox&&(a.bbox.displayControl={...a.bbox.displayControl,[e]:t}),n.includes("mask")&&a.mask&&(a.mask.displayControl={...a.mask.displayControl,[e]:t}),n.includes("bbox")&&n.includes("mask")&&(a.displayControl={...a.displayControl,[e]:t}),a),sortObjectsByModel=a=>a.reduce((e,n)=>n.source_id===PRE_ANNOTATION?(n.review_state||(e[PRE_ANNOTATION]=[n,...e[PRE_ANNOTATION]]),e):(e[n.source_id]=[n,...e[n.source_id]||[]],e),{[GROUND_TRUTH]:[],[PRE_ANNOTATION]:[]}),updateExistingObject=(a,e)=>a.map(n=>(e==null?void 0:e.status)!=="editing"||(e.highlighted==="all"&&(n.highlighted="all"),e.highlighted==="self"&&(n.highlighted=e.shapeId===n.id?"self":"none"),e.shapeId!==n.id)?n:e.type==="mask"&&n.mask?{...n,mask:{...n.mask,counts:e.counts}}:e.type==="rectangle"&&n.bbox?{...n,bbox:{...n.bbox,coords:e.coords}}:n),getObjectsToPreAnnotate=a=>a.filter(e=>e.source_id===PRE_ANNOTATION&&!e.review_state),sortAndFilterObjectsToAnnotate=(a,e)=>a.filter(n=>{var r;return(((r=n.bbox)==null?void 0:r.confidence)||0)>=e[0]}).sort((n,t)=>{var s,l;const r=((s=n.bbox)==null?void 0:s.coords[0])||0,o=((l=t.bbox)==null?void 0:l.coords[0])||0;return r-o}),mapObjectWithNewStatus=(a,e,n,t={})=>{var o;const r=(o=e[1])==null?void 0:o.id;return a.map(s=>{var l;return s.id===r?s.highlighted="self":s.highlighted="none",s.id===((l=e[0])==null?void 0:l.id)&&(s.review_state=n,Object.keys(t||{}).forEach(c=>{s.features[c]&&(s.features[c].value=t[c])})),s})},createObjectCardId=a=>`object-${a.id}`,defineCreatedObject=(a,e,n,t)=>{let r=null;const o={id:nanoid(10),item_id:a.itemId,source_id:GROUND_TRUTH,view_id:a.viewId,features:n};if(a.type==="rectangle"){const{x:s,y:l,width:c,height:f}=a.attrs,u={coords:[s/a.imageWidth,l/a.imageHeight,c/a.imageWidth,f/a.imageHeight],format:"xywh",is_normalized:!0,confidence:1};e==="video"?r={...o,datasetItemType:"video",track:[{start:0,end:t,keyBoxes:[{...u,frameIndex:0},{...u,frameIndex:t}]}],displayedBox:{...u,frameIndex:0}}:r={...o,datasetItemType:"image",bbox:u}}return a.type==="mask"&&(r={...o,datasetItemType:"image",mask:{counts:a.rle.counts,size:a.rle.size}}),r};/**
 * @copyright CEA
 * @author CEA
 * @license CECILL
 *
 * This software is a collaborative computer program whose purpose is to
 * generate and explore labeled data for computer vision applications.
 * This software is governed by the CeCILL-C license under French law and
 * abiding by the rules of distribution of free software. You can use,
 * modify and/ or redistribute the software under the terms of the CeCILL-C
 * license as circulated by CEA, CNRS and INRIA at the following URL
 *
 * http://www.cecill.info
 */const newShape=writable(),selectedTool=writable(),itemObjects=writable([]),interactiveSegmenterModel=writable(),itemMetas=writable(),canSave=writable(!1),preAnnotationIsActive=writable(!1),modelsStore=writable({currentModalOpen:"none",selectedModelName:""}),itemBboxes=derived([itemObjects,itemMetas],([a,e])=>a.reduce((n,t)=>{const r=mapObjectToBBox(t,e==null?void 0:e.views);return r&&n.push(r),n},[])),itemMasks=derived(itemObjects,a=>a.reduce((e,n)=>{const t=mapObjectToMasks(n);return t&&e.push(t),e},[]));function create_default_slot_6(a){let e,n;return e=new Mouse_pointer({}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_default_slot_5$4(a){let e,n;return e=new Square({}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_default_slot_4$5(a){let e,n;return e=new Share_2({}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_default_slot_3$7(a){let e,n,t,r;return e=new Brush({}),t=new MagicIcon({}),{c(){create_component(e.$$.fragment),n=space(),create_component(t.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(t.$$.fragment,o)},m(o,s){mount_component(e,o,s),insert_hydration(o,n,s),mount_component(t,o,s),r=!0},i(o){r||(transition_in(e.$$.fragment,o),transition_in(t.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(t.$$.fragment,o),r=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(t,o)}}}function create_if_block$q(a){var l,c,f;let e,n,t,r,o,s;return e=new TooltipIconButton({props:{tooltipContent:a[2].name,selected:((l=a[0])==null?void 0:l.type)==="POINT_SELECTION"&&!!a[0].label,$$slots:{default:[create_default_slot_2$7]},$$scope:{ctx:a}}}),e.$on("click",a[11]),t=new TooltipIconButton({props:{tooltipContent:a[3].name,selected:((c=a[0])==null?void 0:c.type)==="POINT_SELECTION"&&!a[0].label,$$slots:{default:[create_default_slot_1$a]},$$scope:{ctx:a}}}),t.$on("click",a[12]),o=new TooltipIconButton({props:{tooltipContent:a[1].name,selected:((f=a[0])==null?void 0:f.type)==="RECTANGLE"&&a[0].isSmart,$$slots:{default:[create_default_slot$i]},$$scope:{ctx:a}}}),o.$on("click",a[13]),{c(){create_component(e.$$.fragment),n=space(),create_component(t.$$.fragment),r=space(),create_component(o.$$.fragment)},l(h){claim_component(e.$$.fragment,h),n=claim_space(h),claim_component(t.$$.fragment,h),r=claim_space(h),claim_component(o.$$.fragment,h)},m(h,u){mount_component(e,h,u),insert_hydration(h,n,u),mount_component(t,h,u),insert_hydration(h,r,u),mount_component(o,h,u),s=!0},p(h,u){var _,m,g;const i={};u&4&&(i.tooltipContent=h[2].name),u&1&&(i.selected=((_=h[0])==null?void 0:_.type)==="POINT_SELECTION"&&!!h[0].label),u&16384&&(i.$$scope={dirty:u,ctx:h}),e.$set(i);const d={};u&8&&(d.tooltipContent=h[3].name),u&1&&(d.selected=((m=h[0])==null?void 0:m.type)==="POINT_SELECTION"&&!h[0].label),u&16384&&(d.$$scope={dirty:u,ctx:h}),t.$set(d);const p={};u&2&&(p.tooltipContent=h[1].name),u&1&&(p.selected=((g=h[0])==null?void 0:g.type)==="RECTANGLE"&&h[0].isSmart),u&16384&&(p.$$scope={dirty:u,ctx:h}),o.$set(p)},i(h){s||(transition_in(e.$$.fragment,h),transition_in(t.$$.fragment,h),transition_in(o.$$.fragment,h),s=!0)},o(h){transition_out(e.$$.fragment,h),transition_out(t.$$.fragment,h),transition_out(o.$$.fragment,h),s=!1},d(h){h&&(detach(n),detach(r)),destroy_component(e,h),destroy_component(t,h),destroy_component(o,h)}}}function create_default_slot_2$7(a){let e,n,t,r;return e=new Plus_circle({}),t=new MagicIcon({}),{c(){create_component(e.$$.fragment),n=space(),create_component(t.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(t.$$.fragment,o)},m(o,s){mount_component(e,o,s),insert_hydration(o,n,s),mount_component(t,o,s),r=!0},i(o){r||(transition_in(e.$$.fragment,o),transition_in(t.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(t.$$.fragment,o),r=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(t,o)}}}function create_default_slot_1$a(a){let e,n,t,r;return e=new Minus_circle({}),t=new MagicIcon({}),{c(){create_component(e.$$.fragment),n=space(),create_component(t.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(t.$$.fragment,o)},m(o,s){mount_component(e,o,s),insert_hydration(o,n,s),mount_component(t,o,s),r=!0},i(o){r||(transition_in(e.$$.fragment,o),transition_in(t.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(t.$$.fragment,o),r=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(t,o)}}}function create_default_slot$i(a){let e,n,t,r;return e=new Square({}),t=new MagicIcon({}),{c(){create_component(e.$$.fragment),n=space(),create_component(t.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(t.$$.fragment,o)},m(o,s){mount_component(e,o,s),insert_hydration(o,n,s),mount_component(t,o,s),r=!0},i(o){r||(transition_in(e.$$.fragment,o),transition_in(t.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(t.$$.fragment,o),r=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(t,o)}}}function create_fragment$B(a){var _,m,g;let e,n,t,r,o,s,l,c,f,h,u,i,d;t=new TooltipIconButton({props:{tooltipContent:panTool.name,selected:((_=a[0])==null?void 0:_.type)==="PAN",$$slots:{default:[create_default_slot_6]},$$scope:{ctx:a}}}),t.$on("click",a[8]),o=new TooltipIconButton({props:{tooltipContent:rectangleTool.name,selected:((m=a[0])==null?void 0:m.type)==="RECTANGLE"&&!a[0].isSmart,$$slots:{default:[create_default_slot_5$4]},$$scope:{ctx:a}}}),o.$on("click",a[9]),l=new TooltipIconButton({props:{tooltipContent:polygonTool.name,selected:((g=a[0])==null?void 0:g.type)==="POLYGON",$$slots:{default:[create_default_slot_4$5]},$$scope:{ctx:a}}}),l.$on("click",a[10]),h=new TooltipIconButton({props:{tooltipContent:"Use a smart segmentation model",$$slots:{default:[create_default_slot_3$7]},$$scope:{ctx:a}}}),h.$on("click",a[6]);let p=a[4]&&create_if_block$q(a);return{c(){e=element("div"),n=element("div"),create_component(t.$$.fragment),r=space(),create_component(o.$$.fragment),s=space(),create_component(l.$$.fragment),c=space(),f=element("div"),create_component(h.$$.fragment),u=space(),p&&p.c(),this.h()},l(b){e=claim_element(b,"DIV",{class:!0});var v=children(e);n=claim_element(v,"DIV",{class:!0});var T=children(n);claim_component(t.$$.fragment,T),r=claim_space(T),claim_component(o.$$.fragment,T),s=claim_space(T),claim_component(l.$$.fragment,T),T.forEach(detach),c=claim_space(v),f=claim_element(v,"DIV",{class:!0});var y=children(f);claim_component(h.$$.fragment,y),u=claim_space(y),p&&p.l(y),y.forEach(detach),v.forEach(detach),this.h()},h(){attr(n,"class","flex items-center flex-col gap-4"),attr(f,"class",i=cn("flex items-center flex-col gap-4 mt-4",{"bg-slate-200 rounded-sm":a[4]})),attr(e,"class","h-full shadow-md py-4 px-2 w-16 border-l bg-slate-100 z-10")},m(b,v){insert_hydration(b,e,v),append_hydration(e,n),mount_component(t,n,null),append_hydration(n,r),mount_component(o,n,null),append_hydration(n,s),mount_component(l,n,null),append_hydration(e,c),append_hydration(e,f),mount_component(h,f,null),append_hydration(f,u),p&&p.m(f,null),d=!0},p(b,[v]){var O,P,E;const T={};v&1&&(T.selected=((O=b[0])==null?void 0:O.type)==="PAN"),v&16384&&(T.$$scope={dirty:v,ctx:b}),t.$set(T);const y={};v&1&&(y.selected=((P=b[0])==null?void 0:P.type)==="RECTANGLE"&&!b[0].isSmart),v&16384&&(y.$$scope={dirty:v,ctx:b}),o.$set(y);const w={};v&1&&(w.selected=((E=b[0])==null?void 0:E.type)==="POLYGON"),v&16384&&(w.$$scope={dirty:v,ctx:b}),l.$set(w);const S={};v&16384&&(S.$$scope={dirty:v,ctx:b}),h.$set(S),b[4]?p?(p.p(b,v),v&16&&transition_in(p,1)):(p=create_if_block$q(b),p.c(),transition_in(p,1),p.m(f,null)):p&&(group_outros(),transition_out(p,1,1,()=>{p=null}),check_outros()),(!d||v&16&&i!==(i=cn("flex items-center flex-col gap-4 mt-4",{"bg-slate-200 rounded-sm":b[4]})))&&attr(f,"class",i)},i(b){d||(transition_in(t.$$.fragment,b),transition_in(o.$$.fragment,b),transition_in(l.$$.fragment,b),transition_in(h.$$.fragment,b),transition_in(p),d=!0)},o(b){transition_out(t.$$.fragment,b),transition_out(o.$$.fragment,b),transition_out(l.$$.fragment,b),transition_out(h.$$.fragment,b),transition_out(p),d=!1},d(b){b&&detach(e),destroy_component(t),destroy_component(o),destroy_component(l),destroy_component(h),p&&p.d()}}}function instance$G(a,e,n){let t;component_subscribe(a,selectedTool,p=>n(0,t=p));let r=null,o=!1;const s=p=>{p!==t&&selectedTool.set(p)},l=()=>{o?s(panTool):(s(addSmartPointTool),modelsStore.update(p=>({...p,currentModalOpen:"selectModel"}))),n(4,o=!o)};interactiveSegmenterModel.subscribe(p=>{p&&(n(2,addSmartPointTool.postProcessor=p,addSmartPointTool),n(3,removeSmartPointTool.postProcessor=p,removeSmartPointTool),n(1,smartRectangleTool.postProcessor=p,smartRectangleTool))}),onMount(()=>{s(panTool)});const c=()=>s(panTool),f=()=>s(rectangleTool),h=()=>s(polygonTool),u=()=>s(addSmartPointTool),i=()=>s(removeSmartPointTool),d=()=>s(smartRectangleTool);return a.$$.update=()=>{a.$$.dirty&129&&((!(r!=null&&r.isSmart)||!(t!=null&&t.isSmart))&&newShape.set({status:"none"}),n(7,r=t))},[t,smartRectangleTool,addSmartPointTool,removeSmartPointTool,o,s,l,r,c,f,h,u,i,d]}class Toolbar extends SvelteComponent{constructor(e){super(),init(this,e,instance$G,create_fragment$B,safe_not_equal,{})}}function get_each_context$a(a,e,n){const t=a.slice();return t[18]=e[n],t}function create_default_slot_5$3(a){let e,n,t,r,o,s=[{type:"button"},a[21],{class:t=cn("py-0 rounded-md bg-transparent flex h-10 items-center border border-input bg-white px-3 text-sm ring-offset-background w-full",a[3])}],l={};for(let c=0;c<s.length;c+=1)l=assign(l,s[c]);return{c(){e=element("button"),n=text(a[6]),this.h()},l(c){e=claim_element(c,"BUTTON",{type:!0,class:!0});var f=children(e);n=claim_text(f,a[6]),f.forEach(detach),this.h()},h(){set_attributes(e,l)},m(c,f){insert_hydration(c,e,f),append_hydration(e,n),e.autofocus&&e.focus(),r||(o=action_destroyer(a[21].action(e)),r=!0)},p(c,f){f&64&&set_data_maybe_contenteditable(n,c[6],l.contenteditable),set_attributes(e,l=get_spread_update(s,[{type:"button"},f&2097152&&c[21],f&8&&t!==(t=cn("py-0 rounded-md bg-transparent flex h-10 items-center border border-input bg-white px-3 text-sm ring-offset-background w-full",c[3]))&&{class:t}]))},d(c){c&&detach(e),r=!1,o()}}}function create_if_block$p(a){let e,n,t;function r(s){a[12](s)}let o={placeholder:a[2]};return a[7]!==void 0&&(o.value=a[7]),e=new Command_input({props:o}),binding_callbacks.push(()=>bind(e,"value",r)),e.$on("change",a[13]),e.$on("input",a[9]),{c(){create_component(e.$$.fragment)},l(s){claim_component(e.$$.fragment,s)},m(s,l){mount_component(e,s,l),t=!0},p(s,l){const c={};l&4&&(c.placeholder=s[2]),!n&&l&128&&(n=!0,c.value=s[7],add_flush_callback(()=>n=!1)),e.$set(c)},i(s){t||(transition_in(e.$$.fragment,s),t=!0)},o(s){transition_out(e.$$.fragment,s),t=!1},d(s){destroy_component(e,s)}}}function create_default_slot_4$4(a){let e,n,t=a[18].label+"",r,o,s;return e=new Check({props:{class:cn("mr-2 h-4 w-4",a[1]!==a[18].value&&"text-transparent")}}),{c(){create_component(e.$$.fragment),n=space(),r=text(t),o=space()},l(l){claim_component(e.$$.fragment,l),n=claim_space(l),r=claim_text(l,t),o=claim_space(l)},m(l,c){mount_component(e,l,c),insert_hydration(l,n,c),insert_hydration(l,r,c),insert_hydration(l,o,c),s=!0},p(l,c){const f={};c&3&&(f.class=cn("mr-2 h-4 w-4",l[1]!==l[18].value&&"text-transparent")),e.$set(f),(!s||c&1)&&t!==(t=l[18].label+"")&&set_data(r,t)},i(l){s||(transition_in(e.$$.fragment,l),s=!0)},o(l){transition_out(e.$$.fragment,l),s=!1},d(l){l&&(detach(n),detach(r),detach(o)),destroy_component(e,l)}}}function create_each_block$a(a){let e,n;function t(...r){return a[14](a[17],...r)}return e=new Command_item({props:{value:a[18].value,onSelect:t,$$slots:{default:[create_default_slot_4$4]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,o){mount_component(e,r,o),n=!0},p(r,o){a=r;const s={};o&1&&(s.value=a[18].value),o&131072&&(s.onSelect=t),o&4194307&&(s.$$scope={dirty:o,ctx:a}),e.$set(s)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_default_slot_3$6(a){let e,n,t=ensure_array_like(a[0]),r=[];for(let s=0;s<t.length;s+=1)r[s]=create_each_block$a(get_each_context$a(a,t,s));const o=s=>transition_out(r[s],1,1,()=>{r[s]=null});return{c(){for(let s=0;s<r.length;s+=1)r[s].c();e=empty()},l(s){for(let l=0;l<r.length;l+=1)r[l].l(s);e=empty()},m(s,l){for(let c=0;c<r.length;c+=1)r[c]&&r[c].m(s,l);insert_hydration(s,e,l),n=!0},p(s,l){if(l&131331){t=ensure_array_like(s[0]);let c;for(c=0;c<t.length;c+=1){const f=get_each_context$a(s,t,c);r[c]?(r[c].p(f,l),transition_in(r[c],1)):(r[c]=create_each_block$a(f),r[c].c(),transition_in(r[c],1),r[c].m(e.parentNode,e))}for(group_outros(),c=t.length;c<r.length;c+=1)o(c);check_outros()}},i(s){if(!n){for(let l=0;l<t.length;l+=1)transition_in(r[l]);n=!0}},o(s){r=r.filter(Boolean);for(let l=0;l<r.length;l+=1)transition_out(r[l]);n=!1},d(s){s&&detach(e),destroy_each(r,s)}}}function create_default_slot_2$6(a){let e,n,t,r=a[4]&&create_if_block$p(a);return n=new Command_list({props:{$$slots:{default:[create_default_slot_3$6]},$$scope:{ctx:a}}}),{c(){r&&r.c(),e=space(),create_component(n.$$.fragment)},l(o){r&&r.l(o),e=claim_space(o),claim_component(n.$$.fragment,o)},m(o,s){r&&r.m(o,s),insert_hydration(o,e,s),mount_component(n,o,s),t=!0},p(o,s){o[4]?r?(r.p(o,s),s&16&&transition_in(r,1)):(r=create_if_block$p(o),r.c(),transition_in(r,1),r.m(e.parentNode,e)):r&&(group_outros(),transition_out(r,1,1,()=>{r=null}),check_outros());const l={};s&4325379&&(l.$$scope={dirty:s,ctx:o}),n.$set(l)},i(o){t||(transition_in(r),transition_in(n.$$.fragment,o),t=!0)},o(o){transition_out(r),transition_out(n.$$.fragment,o),t=!1},d(o){o&&detach(e),r&&r.d(o),destroy_component(n,o)}}}function create_default_slot_1$9(a){let e,n;return e=new Command({props:{$$slots:{default:[create_default_slot_2$6]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r&4325527&&(o.$$scope={dirty:r,ctx:t}),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_default_slot$h(a){let e,n,t,r;return e=new Trigger$1({props:{asChild:!0,$$slots:{default:[create_default_slot_5$3,({builder:o})=>({21:o}),({builder:o})=>o?2097152:0]},$$scope:{ctx:a}}}),t=new Popover_content({props:{class:"p-0 ",tabindex:-1,$$slots:{default:[create_default_slot_1$9]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment),n=space(),create_component(t.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(t.$$.fragment,o)},m(o,s){mount_component(e,o,s),insert_hydration(o,n,s),mount_component(t,o,s),r=!0},p(o,s){const l={};s&6291528&&(l.$$scope={dirty:s,ctx:o}),e.$set(l);const c={};s&4325527&&(c.$$scope={dirty:s,ctx:o}),t.$set(c)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(t.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(t.$$.fragment,o),r=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(t,o)}}}function create_fragment$A(a){let e,n,t;function r(s){a[15](s)}let o={$$slots:{default:[create_default_slot$h,({ids:s})=>({17:s}),({ids:s})=>s?131072:0]},$$scope:{ctx:a}};return a[5]!==void 0&&(o.open=a[5]),e=new Root$1({props:o}),binding_callbacks.push(()=>bind(e,"open",r)),{c(){create_component(e.$$.fragment)},l(s){claim_component(e.$$.fragment,s)},m(s,l){mount_component(e,s,l),t=!0},p(s,[l]){const c={};l&4325599&&(c.$$scope={dirty:l,ctx:s}),!n&&l&32&&(n=!0,c.open=s[5],add_flush_callback(()=>n=!1)),e.$set(c)},i(s){t||(transition_in(e.$$.fragment,s),t=!0)},o(s){transition_out(e.$$.fragment,s),t=!1},d(s){destroy_component(e,s)}}}function instance$F(a,e,n){let{onTextInputChange:t}=e,{featureList:r=[]}=e,{placeholder:o="Select a feature"}=e,{value:s=""}=e,{autofocus:l=!1}=e,{className:c=""}=e,{isInputEnabled:f=!0}=e,h=l,u=s||o,i=s;function d(T){n(5,h=!1),tick().then(()=>{var y;(y=document.getElementById(T))==null||y.focus()}).catch(y=>console.error(y))}const p=(T,y)=>{n(1,s=T),t(s),d(y)},_=()=>{var y;!((y=r.find(w=>w.value===i))==null?void 0:y.label)&&i&&n(0,r=[...r,{value:i,label:i}])};function m(T){i=T,n(7,i)}const g=()=>console.log("changed"),b=(T,y)=>p(y,T.trigger);function v(T){h=T,n(5,h)}return a.$$set=T=>{"onTextInputChange"in T&&n(10,t=T.onTextInputChange),"featureList"in T&&n(0,r=T.featureList),"placeholder"in T&&n(2,o=T.placeholder),"value"in T&&n(1,s=T.value),"autofocus"in T&&n(11,l=T.autofocus),"className"in T&&n(3,c=T.className),"isInputEnabled"in T&&n(4,f=T.isInputEnabled)},a.$$.update=()=>{var T;a.$$.dirty&7&&n(6,u=((T=r.find(y=>y.value===s))==null?void 0:T.label)??o)},[r,s,o,c,f,h,u,i,p,_,t,l,m,g,b,v]}class AutoCompleteFeatureInput extends SvelteComponent{constructor(e){super(),init(this,e,instance$F,create_fragment$A,safe_not_equal,{onTextInputChange:10,featureList:0,placeholder:2,value:1,autofocus:11,className:3,isInputEnabled:4})}}var util;(function(a){a.assertEqual=r=>r;function e(r){}a.assertIs=e;function n(r){throw new Error}a.assertNever=n,a.arrayToEnum=r=>{const o={};for(const s of r)o[s]=s;return o},a.getValidEnumValues=r=>{const o=a.objectKeys(r).filter(l=>typeof r[r[l]]!="number"),s={};for(const l of o)s[l]=r[l];return a.objectValues(s)},a.objectValues=r=>a.objectKeys(r).map(function(o){return r[o]}),a.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const o=[];for(const s in r)Object.prototype.hasOwnProperty.call(r,s)&&o.push(s);return o},a.find=(r,o)=>{for(const s of r)if(o(s))return s},a.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function t(r,o=" | "){return r.map(s=>typeof s=="string"?`'${s}'`:s).join(o)}a.joinValues=t,a.jsonStringifyReplacer=(r,o)=>typeof o=="bigint"?o.toString():o})(util||(util={}));var objectUtil;(function(a){a.mergeShapes=(e,n)=>({...e,...n})})(objectUtil||(objectUtil={}));const ZodParsedType=util.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),getParsedType=a=>{switch(typeof a){case"undefined":return ZodParsedType.undefined;case"string":return ZodParsedType.string;case"number":return isNaN(a)?ZodParsedType.nan:ZodParsedType.number;case"boolean":return ZodParsedType.boolean;case"function":return ZodParsedType.function;case"bigint":return ZodParsedType.bigint;case"symbol":return ZodParsedType.symbol;case"object":return Array.isArray(a)?ZodParsedType.array:a===null?ZodParsedType.null:a.then&&typeof a.then=="function"&&a.catch&&typeof a.catch=="function"?ZodParsedType.promise:typeof Map<"u"&&a instanceof Map?ZodParsedType.map:typeof Set<"u"&&a instanceof Set?ZodParsedType.set:typeof Date<"u"&&a instanceof Date?ZodParsedType.date:ZodParsedType.object;default:return ZodParsedType.unknown}},ZodIssueCode=util.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),quotelessJson=a=>JSON.stringify(a,null,2).replace(/"([^"]+)":/g,"$1:");class ZodError extends Error{constructor(e){super(),this.issues=[],this.addIssue=t=>{this.issues=[...this.issues,t]},this.addIssues=(t=[])=>{this.issues=[...this.issues,...t]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const n=e||function(o){return o.message},t={_errors:[]},r=o=>{for(const s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(r);else if(s.code==="invalid_return_type")r(s.returnTypeError);else if(s.code==="invalid_arguments")r(s.argumentsError);else if(s.path.length===0)t._errors.push(n(s));else{let l=t,c=0;for(;c<s.path.length;){const f=s.path[c];c===s.path.length-1?(l[f]=l[f]||{_errors:[]},l[f]._errors.push(n(s))):l[f]=l[f]||{_errors:[]},l=l[f],c++}}};return r(this),t}toString(){return this.message}get message(){return JSON.stringify(this.issues,util.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},t=[];for(const r of this.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(e(r))):t.push(e(r));return{formErrors:t,fieldErrors:n}}get formErrors(){return this.flatten()}}ZodError.create=a=>new ZodError(a);const errorMap=(a,e)=>{let n;switch(a.code){case ZodIssueCode.invalid_type:a.received===ZodParsedType.undefined?n="Required":n=`Expected ${a.expected}, received ${a.received}`;break;case ZodIssueCode.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(a.expected,util.jsonStringifyReplacer)}`;break;case ZodIssueCode.unrecognized_keys:n=`Unrecognized key(s) in object: ${util.joinValues(a.keys,", ")}`;break;case ZodIssueCode.invalid_union:n="Invalid input";break;case ZodIssueCode.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${util.joinValues(a.options)}`;break;case ZodIssueCode.invalid_enum_value:n=`Invalid enum value. Expected ${util.joinValues(a.options)}, received '${a.received}'`;break;case ZodIssueCode.invalid_arguments:n="Invalid function arguments";break;case ZodIssueCode.invalid_return_type:n="Invalid function return type";break;case ZodIssueCode.invalid_date:n="Invalid date";break;case ZodIssueCode.invalid_string:typeof a.validation=="object"?"includes"in a.validation?(n=`Invalid input: must include "${a.validation.includes}"`,typeof a.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${a.validation.position}`)):"startsWith"in a.validation?n=`Invalid input: must start with "${a.validation.startsWith}"`:"endsWith"in a.validation?n=`Invalid input: must end with "${a.validation.endsWith}"`:util.assertNever(a.validation):a.validation!=="regex"?n=`Invalid ${a.validation}`:n="Invalid";break;case ZodIssueCode.too_small:a.type==="array"?n=`Array must contain ${a.exact?"exactly":a.inclusive?"at least":"more than"} ${a.minimum} element(s)`:a.type==="string"?n=`String must contain ${a.exact?"exactly":a.inclusive?"at least":"over"} ${a.minimum} character(s)`:a.type==="number"?n=`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:a.type==="date"?n=`Date must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(a.minimum))}`:n="Invalid input";break;case ZodIssueCode.too_big:a.type==="array"?n=`Array must contain ${a.exact?"exactly":a.inclusive?"at most":"less than"} ${a.maximum} element(s)`:a.type==="string"?n=`String must contain ${a.exact?"exactly":a.inclusive?"at most":"under"} ${a.maximum} character(s)`:a.type==="number"?n=`Number must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="bigint"?n=`BigInt must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="date"?n=`Date must be ${a.exact?"exactly":a.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(a.maximum))}`:n="Invalid input";break;case ZodIssueCode.custom:n="Invalid input";break;case ZodIssueCode.invalid_intersection_types:n="Intersection results could not be merged";break;case ZodIssueCode.not_multiple_of:n=`Number must be a multiple of ${a.multipleOf}`;break;case ZodIssueCode.not_finite:n="Number must be finite";break;default:n=e.defaultError,util.assertNever(a)}return{message:n}};let overrideErrorMap=errorMap;function setErrorMap(a){overrideErrorMap=a}function getErrorMap(){return overrideErrorMap}const makeIssue=a=>{const{data:e,path:n,errorMaps:t,issueData:r}=a,o=[...n,...r.path||[]],s={...r,path:o};let l="";const c=t.filter(f=>!!f).slice().reverse();for(const f of c)l=f(s,{data:e,defaultError:l}).message;return{...r,path:o,message:r.message||l}},EMPTY_PATH=[];function addIssueToContext(a,e){const n=makeIssue({issueData:e,data:a.data,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,getErrorMap(),errorMap].filter(t=>!!t)});a.common.issues.push(n)}class ParseStatus{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const t=[];for(const r of n){if(r.status==="aborted")return INVALID;r.status==="dirty"&&e.dirty(),t.push(r.value)}return{status:e.value,value:t}}static async mergeObjectAsync(e,n){const t=[];for(const r of n)t.push({key:await r.key,value:await r.value});return ParseStatus.mergeObjectSync(e,t)}static mergeObjectSync(e,n){const t={};for(const r of n){const{key:o,value:s}=r;if(o.status==="aborted"||s.status==="aborted")return INVALID;o.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof s.value<"u"||r.alwaysSet)&&(t[o.value]=s.value)}return{status:e.value,value:t}}}const INVALID=Object.freeze({status:"aborted"}),DIRTY=a=>({status:"dirty",value:a}),OK=a=>({status:"valid",value:a}),isAborted=a=>a.status==="aborted",isDirty=a=>a.status==="dirty",isValid=a=>a.status==="valid",isAsync=a=>typeof Promise<"u"&&a instanceof Promise;var errorUtil;(function(a){a.errToObj=e=>typeof e=="string"?{message:e}:e||{},a.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(errorUtil||(errorUtil={}));class ParseInputLazyPath{constructor(e,n,t,r){this._cachedPath=[],this.parent=e,this.data=n,this._path=t,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const handleResult=(a,e)=>{if(isValid(e))return{success:!0,data:e.value};if(!a.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new ZodError(a.common.issues);return this._error=n,this._error}}};function processCreateParams(a){if(!a)return{};const{errorMap:e,invalid_type_error:n,required_error:t,description:r}=a;if(e&&(n||t))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(s,l)=>s.code!=="invalid_type"?{message:l.defaultError}:typeof l.data>"u"?{message:t??l.defaultError}:{message:n??l.defaultError},description:r}}class ZodType{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return getParsedType(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:getParsedType(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ParseStatus,ctx:{common:e.parent.common,data:e.data,parsedType:getParsedType(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(isAsync(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const t=this.safeParse(e,n);if(t.success)return t.data;throw t.error}safeParse(e,n){var t;const r={common:{issues:[],async:(t=n==null?void 0:n.async)!==null&&t!==void 0?t:!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:getParsedType(e)},o=this._parseSync({data:e,path:r.path,parent:r});return handleResult(r,o)}async parseAsync(e,n){const t=await this.safeParseAsync(e,n);if(t.success)return t.data;throw t.error}async safeParseAsync(e,n){const t={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:getParsedType(e)},r=this._parse({data:e,path:t.path,parent:t}),o=await(isAsync(r)?r:Promise.resolve(r));return handleResult(t,o)}refine(e,n){const t=r=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(r):n;return this._refinement((r,o)=>{const s=e(r),l=()=>o.addIssue({code:ZodIssueCode.custom,...t(r)});return typeof Promise<"u"&&s instanceof Promise?s.then(c=>c?!0:(l(),!1)):s?!0:(l(),!1)})}refinement(e,n){return this._refinement((t,r)=>e(t)?!0:(r.addIssue(typeof n=="function"?n(t,r):n),!1))}_refinement(e){return new ZodEffects({schema:this,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ZodOptional.create(this,this._def)}nullable(){return ZodNullable.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ZodArray.create(this,this._def)}promise(){return ZodPromise.create(this,this._def)}or(e){return ZodUnion.create([this,e],this._def)}and(e){return ZodIntersection.create(this,e,this._def)}transform(e){return new ZodEffects({...processCreateParams(this._def),schema:this,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new ZodDefault({...processCreateParams(this._def),innerType:this,defaultValue:n,typeName:ZodFirstPartyTypeKind.ZodDefault})}brand(){return new ZodBranded({typeName:ZodFirstPartyTypeKind.ZodBranded,type:this,...processCreateParams(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new ZodCatch({...processCreateParams(this._def),innerType:this,catchValue:n,typeName:ZodFirstPartyTypeKind.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return ZodPipeline.create(this,e)}readonly(){return ZodReadonly.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const cuidRegex=/^c[^\s-]{8,}$/i,cuid2Regex=/^[a-z][a-z0-9]*$/,ulidRegex=/^[0-9A-HJKMNP-TV-Z]{26}$/,uuidRegex=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,emailRegex=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_emojiRegex="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let emojiRegex;const ipv4Regex=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,ipv6Regex=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,datetimeRegex=a=>a.precision?a.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${a.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${a.precision}}Z$`):a.precision===0?a.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):a.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function isValidIP(a,e){return!!((e==="v4"||!e)&&ipv4Regex.test(a)||(e==="v6"||!e)&&ipv6Regex.test(a))}class ZodString extends ZodType{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ZodParsedType.string){const o=this._getOrReturnCtx(e);return addIssueToContext(o,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.string,received:o.parsedType}),INVALID}const t=new ParseStatus;let r;for(const o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),t.dirty());else if(o.kind==="max")e.data.length>o.value&&(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),t.dirty());else if(o.kind==="length"){const s=e.data.length>o.value,l=e.data.length<o.value;(s||l)&&(r=this._getOrReturnCtx(e,r),s?addIssueToContext(r,{code:ZodIssueCode.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):l&&addIssueToContext(r,{code:ZodIssueCode.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),t.dirty())}else if(o.kind==="email")emailRegex.test(e.data)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{validation:"email",code:ZodIssueCode.invalid_string,message:o.message}),t.dirty());else if(o.kind==="emoji")emojiRegex||(emojiRegex=new RegExp(_emojiRegex,"u")),emojiRegex.test(e.data)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{validation:"emoji",code:ZodIssueCode.invalid_string,message:o.message}),t.dirty());else if(o.kind==="uuid")uuidRegex.test(e.data)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{validation:"uuid",code:ZodIssueCode.invalid_string,message:o.message}),t.dirty());else if(o.kind==="cuid")cuidRegex.test(e.data)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{validation:"cuid",code:ZodIssueCode.invalid_string,message:o.message}),t.dirty());else if(o.kind==="cuid2")cuid2Regex.test(e.data)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{validation:"cuid2",code:ZodIssueCode.invalid_string,message:o.message}),t.dirty());else if(o.kind==="ulid")ulidRegex.test(e.data)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{validation:"ulid",code:ZodIssueCode.invalid_string,message:o.message}),t.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),addIssueToContext(r,{validation:"url",code:ZodIssueCode.invalid_string,message:o.message}),t.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{validation:"regex",code:ZodIssueCode.invalid_string,message:o.message}),t.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),t.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.invalid_string,validation:{startsWith:o.value},message:o.message}),t.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.invalid_string,validation:{endsWith:o.value},message:o.message}),t.dirty()):o.kind==="datetime"?datetimeRegex(o).test(e.data)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.invalid_string,validation:"datetime",message:o.message}),t.dirty()):o.kind==="ip"?isValidIP(e.data,o.version)||(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{validation:"ip",code:ZodIssueCode.invalid_string,message:o.message}),t.dirty()):util.assertNever(o);return{status:t.value,value:e.data}}_regex(e,n,t){return this.refinement(r=>e.test(r),{validation:n,code:ZodIssueCode.invalid_string,...errorUtil.errToObj(t)})}_addCheck(e){return new ZodString({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...errorUtil.errToObj(e)})}url(e){return this._addCheck({kind:"url",...errorUtil.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...errorUtil.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...errorUtil.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...errorUtil.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...errorUtil.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...errorUtil.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...errorUtil.errToObj(e)})}datetime(e){var n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(n=e==null?void 0:e.offset)!==null&&n!==void 0?n:!1,...errorUtil.errToObj(e==null?void 0:e.message)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...errorUtil.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...errorUtil.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...errorUtil.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...errorUtil.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...errorUtil.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...errorUtil.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...errorUtil.errToObj(n)})}nonempty(e){return this.min(1,errorUtil.errToObj(e))}trim(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}ZodString.create=a=>{var e;return new ZodString({checks:[],typeName:ZodFirstPartyTypeKind.ZodString,coerce:(e=a==null?void 0:a.coerce)!==null&&e!==void 0?e:!1,...processCreateParams(a)})};function floatSafeRemainder(a,e){const n=(a.toString().split(".")[1]||"").length,t=(e.toString().split(".")[1]||"").length,r=n>t?n:t,o=parseInt(a.toFixed(r).replace(".","")),s=parseInt(e.toFixed(r).replace(".",""));return o%s/Math.pow(10,r)}class ZodNumber extends ZodType{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==ZodParsedType.number){const o=this._getOrReturnCtx(e);return addIssueToContext(o,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.number,received:o.parsedType}),INVALID}let t;const r=new ParseStatus;for(const o of this._def.checks)o.kind==="int"?util.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:"integer",received:"float",message:o.message}),r.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:ZodIssueCode.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),r.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:ZodIssueCode.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),r.dirty()):o.kind==="multipleOf"?floatSafeRemainder(e.data,o.value)!==0&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:ZodIssueCode.not_multiple_of,multipleOf:o.value,message:o.message}),r.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:ZodIssueCode.not_finite,message:o.message}),r.dirty()):util.assertNever(o);return{status:r.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,errorUtil.toString(n))}gt(e,n){return this.setLimit("min",e,!1,errorUtil.toString(n))}lte(e,n){return this.setLimit("max",e,!0,errorUtil.toString(n))}lt(e,n){return this.setLimit("max",e,!1,errorUtil.toString(n))}setLimit(e,n,t,r){return new ZodNumber({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:t,message:errorUtil.toString(r)}]})}_addCheck(e){return new ZodNumber({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:errorUtil.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:errorUtil.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:errorUtil.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:errorUtil.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:errorUtil.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:errorUtil.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&util.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const t of this._def.checks){if(t.kind==="finite"||t.kind==="int"||t.kind==="multipleOf")return!0;t.kind==="min"?(n===null||t.value>n)&&(n=t.value):t.kind==="max"&&(e===null||t.value<e)&&(e=t.value)}return Number.isFinite(n)&&Number.isFinite(e)}}ZodNumber.create=a=>new ZodNumber({checks:[],typeName:ZodFirstPartyTypeKind.ZodNumber,coerce:(a==null?void 0:a.coerce)||!1,...processCreateParams(a)});class ZodBigInt extends ZodType{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==ZodParsedType.bigint){const o=this._getOrReturnCtx(e);return addIssueToContext(o,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.bigint,received:o.parsedType}),INVALID}let t;const r=new ParseStatus;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:ZodIssueCode.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),r.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:ZodIssueCode.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),r.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),addIssueToContext(t,{code:ZodIssueCode.not_multiple_of,multipleOf:o.value,message:o.message}),r.dirty()):util.assertNever(o);return{status:r.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,errorUtil.toString(n))}gt(e,n){return this.setLimit("min",e,!1,errorUtil.toString(n))}lte(e,n){return this.setLimit("max",e,!0,errorUtil.toString(n))}lt(e,n){return this.setLimit("max",e,!1,errorUtil.toString(n))}setLimit(e,n,t,r){return new ZodBigInt({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:t,message:errorUtil.toString(r)}]})}_addCheck(e){return new ZodBigInt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:errorUtil.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:errorUtil.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}ZodBigInt.create=a=>{var e;return new ZodBigInt({checks:[],typeName:ZodFirstPartyTypeKind.ZodBigInt,coerce:(e=a==null?void 0:a.coerce)!==null&&e!==void 0?e:!1,...processCreateParams(a)})};class ZodBoolean extends ZodType{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ZodParsedType.boolean){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.boolean,received:t.parsedType}),INVALID}return OK(e.data)}}ZodBoolean.create=a=>new ZodBoolean({typeName:ZodFirstPartyTypeKind.ZodBoolean,coerce:(a==null?void 0:a.coerce)||!1,...processCreateParams(a)});class ZodDate extends ZodType{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ZodParsedType.date){const o=this._getOrReturnCtx(e);return addIssueToContext(o,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.date,received:o.parsedType}),INVALID}if(isNaN(e.data.getTime())){const o=this._getOrReturnCtx(e);return addIssueToContext(o,{code:ZodIssueCode.invalid_date}),INVALID}const t=new ParseStatus;let r;for(const o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),t.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(r=this._getOrReturnCtx(e,r),addIssueToContext(r,{code:ZodIssueCode.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),t.dirty()):util.assertNever(o);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ZodDate({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:errorUtil.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:errorUtil.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}ZodDate.create=a=>new ZodDate({checks:[],coerce:(a==null?void 0:a.coerce)||!1,typeName:ZodFirstPartyTypeKind.ZodDate,...processCreateParams(a)});class ZodSymbol extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.symbol){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.symbol,received:t.parsedType}),INVALID}return OK(e.data)}}ZodSymbol.create=a=>new ZodSymbol({typeName:ZodFirstPartyTypeKind.ZodSymbol,...processCreateParams(a)});class ZodUndefined extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.undefined){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.undefined,received:t.parsedType}),INVALID}return OK(e.data)}}ZodUndefined.create=a=>new ZodUndefined({typeName:ZodFirstPartyTypeKind.ZodUndefined,...processCreateParams(a)});class ZodNull extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.null){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.null,received:t.parsedType}),INVALID}return OK(e.data)}}ZodNull.create=a=>new ZodNull({typeName:ZodFirstPartyTypeKind.ZodNull,...processCreateParams(a)});class ZodAny extends ZodType{constructor(){super(...arguments),this._any=!0}_parse(e){return OK(e.data)}}ZodAny.create=a=>new ZodAny({typeName:ZodFirstPartyTypeKind.ZodAny,...processCreateParams(a)});class ZodUnknown extends ZodType{constructor(){super(...arguments),this._unknown=!0}_parse(e){return OK(e.data)}}ZodUnknown.create=a=>new ZodUnknown({typeName:ZodFirstPartyTypeKind.ZodUnknown,...processCreateParams(a)});class ZodNever extends ZodType{_parse(e){const n=this._getOrReturnCtx(e);return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.never,received:n.parsedType}),INVALID}}ZodNever.create=a=>new ZodNever({typeName:ZodFirstPartyTypeKind.ZodNever,...processCreateParams(a)});class ZodVoid extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.undefined){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.void,received:t.parsedType}),INVALID}return OK(e.data)}}ZodVoid.create=a=>new ZodVoid({typeName:ZodFirstPartyTypeKind.ZodVoid,...processCreateParams(a)});class ZodArray extends ZodType{_parse(e){const{ctx:n,status:t}=this._processInputParams(e),r=this._def;if(n.parsedType!==ZodParsedType.array)return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.array,received:n.parsedType}),INVALID;if(r.exactLength!==null){const s=n.data.length>r.exactLength.value,l=n.data.length<r.exactLength.value;(s||l)&&(addIssueToContext(n,{code:s?ZodIssueCode.too_big:ZodIssueCode.too_small,minimum:l?r.exactLength.value:void 0,maximum:s?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),t.dirty())}if(r.minLength!==null&&n.data.length<r.minLength.value&&(addIssueToContext(n,{code:ZodIssueCode.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),t.dirty()),r.maxLength!==null&&n.data.length>r.maxLength.value&&(addIssueToContext(n,{code:ZodIssueCode.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),t.dirty()),n.common.async)return Promise.all([...n.data].map((s,l)=>r.type._parseAsync(new ParseInputLazyPath(n,s,n.path,l)))).then(s=>ParseStatus.mergeArray(t,s));const o=[...n.data].map((s,l)=>r.type._parseSync(new ParseInputLazyPath(n,s,n.path,l)));return ParseStatus.mergeArray(t,o)}get element(){return this._def.type}min(e,n){return new ZodArray({...this._def,minLength:{value:e,message:errorUtil.toString(n)}})}max(e,n){return new ZodArray({...this._def,maxLength:{value:e,message:errorUtil.toString(n)}})}length(e,n){return new ZodArray({...this._def,exactLength:{value:e,message:errorUtil.toString(n)}})}nonempty(e){return this.min(1,e)}}ZodArray.create=(a,e)=>new ZodArray({type:a,minLength:null,maxLength:null,exactLength:null,typeName:ZodFirstPartyTypeKind.ZodArray,...processCreateParams(e)});function deepPartialify(a){if(a instanceof ZodObject){const e={};for(const n in a.shape){const t=a.shape[n];e[n]=ZodOptional.create(deepPartialify(t))}return new ZodObject({...a._def,shape:()=>e})}else return a instanceof ZodArray?new ZodArray({...a._def,type:deepPartialify(a.element)}):a instanceof ZodOptional?ZodOptional.create(deepPartialify(a.unwrap())):a instanceof ZodNullable?ZodNullable.create(deepPartialify(a.unwrap())):a instanceof ZodTuple?ZodTuple.create(a.items.map(e=>deepPartialify(e))):a}class ZodObject extends ZodType{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=util.objectKeys(e);return this._cached={shape:e,keys:n}}_parse(e){if(this._getType(e)!==ZodParsedType.object){const f=this._getOrReturnCtx(e);return addIssueToContext(f,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:f.parsedType}),INVALID}const{status:t,ctx:r}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),l=[];if(!(this._def.catchall instanceof ZodNever&&this._def.unknownKeys==="strip"))for(const f in r.data)s.includes(f)||l.push(f);const c=[];for(const f of s){const h=o[f],u=r.data[f];c.push({key:{status:"valid",value:f},value:h._parse(new ParseInputLazyPath(r,u,r.path,f)),alwaysSet:f in r.data})}if(this._def.catchall instanceof ZodNever){const f=this._def.unknownKeys;if(f==="passthrough")for(const h of l)c.push({key:{status:"valid",value:h},value:{status:"valid",value:r.data[h]}});else if(f==="strict")l.length>0&&(addIssueToContext(r,{code:ZodIssueCode.unrecognized_keys,keys:l}),t.dirty());else if(f!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const f=this._def.catchall;for(const h of l){const u=r.data[h];c.push({key:{status:"valid",value:h},value:f._parse(new ParseInputLazyPath(r,u,r.path,h)),alwaysSet:h in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const f=[];for(const h of c){const u=await h.key;f.push({key:u,value:await h.value,alwaysSet:h.alwaysSet})}return f}).then(f=>ParseStatus.mergeObjectSync(t,f)):ParseStatus.mergeObjectSync(t,c)}get shape(){return this._def.shape()}strict(e){return errorUtil.errToObj,new ZodObject({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,t)=>{var r,o,s,l;const c=(s=(o=(r=this._def).errorMap)===null||o===void 0?void 0:o.call(r,n,t).message)!==null&&s!==void 0?s:t.defaultError;return n.code==="unrecognized_keys"?{message:(l=errorUtil.errToObj(e).message)!==null&&l!==void 0?l:c}:{message:c}}}:{}})}strip(){return new ZodObject({...this._def,unknownKeys:"strip"})}passthrough(){return new ZodObject({...this._def,unknownKeys:"passthrough"})}extend(e){return new ZodObject({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ZodObject({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ZodFirstPartyTypeKind.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new ZodObject({...this._def,catchall:e})}pick(e){const n={};return util.objectKeys(e).forEach(t=>{e[t]&&this.shape[t]&&(n[t]=this.shape[t])}),new ZodObject({...this._def,shape:()=>n})}omit(e){const n={};return util.objectKeys(this.shape).forEach(t=>{e[t]||(n[t]=this.shape[t])}),new ZodObject({...this._def,shape:()=>n})}deepPartial(){return deepPartialify(this)}partial(e){const n={};return util.objectKeys(this.shape).forEach(t=>{const r=this.shape[t];e&&!e[t]?n[t]=r:n[t]=r.optional()}),new ZodObject({...this._def,shape:()=>n})}required(e){const n={};return util.objectKeys(this.shape).forEach(t=>{if(e&&!e[t])n[t]=this.shape[t];else{let o=this.shape[t];for(;o instanceof ZodOptional;)o=o._def.innerType;n[t]=o}}),new ZodObject({...this._def,shape:()=>n})}keyof(){return createZodEnum(util.objectKeys(this.shape))}}ZodObject.create=(a,e)=>new ZodObject({shape:()=>a,unknownKeys:"strip",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(e)});ZodObject.strictCreate=(a,e)=>new ZodObject({shape:()=>a,unknownKeys:"strict",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(e)});ZodObject.lazycreate=(a,e)=>new ZodObject({shape:a,unknownKeys:"strip",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(e)});class ZodUnion extends ZodType{_parse(e){const{ctx:n}=this._processInputParams(e),t=this._def.options;function r(o){for(const l of o)if(l.result.status==="valid")return l.result;for(const l of o)if(l.result.status==="dirty")return n.common.issues.push(...l.ctx.common.issues),l.result;const s=o.map(l=>new ZodError(l.ctx.common.issues));return addIssueToContext(n,{code:ZodIssueCode.invalid_union,unionErrors:s}),INVALID}if(n.common.async)return Promise.all(t.map(async o=>{const s={...n,common:{...n.common,issues:[]},parent:null};return{result:await o._parseAsync({data:n.data,path:n.path,parent:s}),ctx:s}})).then(r);{let o;const s=[];for(const c of t){const f={...n,common:{...n.common,issues:[]},parent:null},h=c._parseSync({data:n.data,path:n.path,parent:f});if(h.status==="valid")return h;h.status==="dirty"&&!o&&(o={result:h,ctx:f}),f.common.issues.length&&s.push(f.common.issues)}if(o)return n.common.issues.push(...o.ctx.common.issues),o.result;const l=s.map(c=>new ZodError(c));return addIssueToContext(n,{code:ZodIssueCode.invalid_union,unionErrors:l}),INVALID}}get options(){return this._def.options}}ZodUnion.create=(a,e)=>new ZodUnion({options:a,typeName:ZodFirstPartyTypeKind.ZodUnion,...processCreateParams(e)});const getDiscriminator=a=>a instanceof ZodLazy?getDiscriminator(a.schema):a instanceof ZodEffects?getDiscriminator(a.innerType()):a instanceof ZodLiteral?[a.value]:a instanceof ZodEnum?a.options:a instanceof ZodNativeEnum?Object.keys(a.enum):a instanceof ZodDefault?getDiscriminator(a._def.innerType):a instanceof ZodUndefined?[void 0]:a instanceof ZodNull?[null]:null;class ZodDiscriminatedUnion extends ZodType{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==ZodParsedType.object)return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:n.parsedType}),INVALID;const t=this.discriminator,r=n.data[t],o=this.optionsMap.get(r);return o?n.common.async?o._parseAsync({data:n.data,path:n.path,parent:n}):o._parseSync({data:n.data,path:n.path,parent:n}):(addIssueToContext(n,{code:ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[t]}),INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,t){const r=new Map;for(const o of n){const s=getDiscriminator(o.shape[e]);if(!s)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const l of s){if(r.has(l))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(l)}`);r.set(l,o)}}return new ZodDiscriminatedUnion({typeName:ZodFirstPartyTypeKind.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:r,...processCreateParams(t)})}}function mergeValues(a,e){const n=getParsedType(a),t=getParsedType(e);if(a===e)return{valid:!0,data:a};if(n===ZodParsedType.object&&t===ZodParsedType.object){const r=util.objectKeys(e),o=util.objectKeys(a).filter(l=>r.indexOf(l)!==-1),s={...a,...e};for(const l of o){const c=mergeValues(a[l],e[l]);if(!c.valid)return{valid:!1};s[l]=c.data}return{valid:!0,data:s}}else if(n===ZodParsedType.array&&t===ZodParsedType.array){if(a.length!==e.length)return{valid:!1};const r=[];for(let o=0;o<a.length;o++){const s=a[o],l=e[o],c=mergeValues(s,l);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===ZodParsedType.date&&t===ZodParsedType.date&&+a==+e?{valid:!0,data:a}:{valid:!1}}class ZodIntersection extends ZodType{_parse(e){const{status:n,ctx:t}=this._processInputParams(e),r=(o,s)=>{if(isAborted(o)||isAborted(s))return INVALID;const l=mergeValues(o.value,s.value);return l.valid?((isDirty(o)||isDirty(s))&&n.dirty(),{status:n.value,value:l.data}):(addIssueToContext(t,{code:ZodIssueCode.invalid_intersection_types}),INVALID)};return t.common.async?Promise.all([this._def.left._parseAsync({data:t.data,path:t.path,parent:t}),this._def.right._parseAsync({data:t.data,path:t.path,parent:t})]).then(([o,s])=>r(o,s)):r(this._def.left._parseSync({data:t.data,path:t.path,parent:t}),this._def.right._parseSync({data:t.data,path:t.path,parent:t}))}}ZodIntersection.create=(a,e,n)=>new ZodIntersection({left:a,right:e,typeName:ZodFirstPartyTypeKind.ZodIntersection,...processCreateParams(n)});class ZodTuple extends ZodType{_parse(e){const{status:n,ctx:t}=this._processInputParams(e);if(t.parsedType!==ZodParsedType.array)return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.array,received:t.parsedType}),INVALID;if(t.data.length<this._def.items.length)return addIssueToContext(t,{code:ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),INVALID;!this._def.rest&&t.data.length>this._def.items.length&&(addIssueToContext(t,{code:ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const o=[...t.data].map((s,l)=>{const c=this._def.items[l]||this._def.rest;return c?c._parse(new ParseInputLazyPath(t,s,t.path,l)):null}).filter(s=>!!s);return t.common.async?Promise.all(o).then(s=>ParseStatus.mergeArray(n,s)):ParseStatus.mergeArray(n,o)}get items(){return this._def.items}rest(e){return new ZodTuple({...this._def,rest:e})}}ZodTuple.create=(a,e)=>{if(!Array.isArray(a))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ZodTuple({items:a,typeName:ZodFirstPartyTypeKind.ZodTuple,rest:null,...processCreateParams(e)})};class ZodRecord extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:t}=this._processInputParams(e);if(t.parsedType!==ZodParsedType.object)return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:t.parsedType}),INVALID;const r=[],o=this._def.keyType,s=this._def.valueType;for(const l in t.data)r.push({key:o._parse(new ParseInputLazyPath(t,l,t.path,l)),value:s._parse(new ParseInputLazyPath(t,t.data[l],t.path,l))});return t.common.async?ParseStatus.mergeObjectAsync(n,r):ParseStatus.mergeObjectSync(n,r)}get element(){return this._def.valueType}static create(e,n,t){return n instanceof ZodType?new ZodRecord({keyType:e,valueType:n,typeName:ZodFirstPartyTypeKind.ZodRecord,...processCreateParams(t)}):new ZodRecord({keyType:ZodString.create(),valueType:e,typeName:ZodFirstPartyTypeKind.ZodRecord,...processCreateParams(n)})}}class ZodMap extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:t}=this._processInputParams(e);if(t.parsedType!==ZodParsedType.map)return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.map,received:t.parsedType}),INVALID;const r=this._def.keyType,o=this._def.valueType,s=[...t.data.entries()].map(([l,c],f)=>({key:r._parse(new ParseInputLazyPath(t,l,t.path,[f,"key"])),value:o._parse(new ParseInputLazyPath(t,c,t.path,[f,"value"]))}));if(t.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const c of s){const f=await c.key,h=await c.value;if(f.status==="aborted"||h.status==="aborted")return INVALID;(f.status==="dirty"||h.status==="dirty")&&n.dirty(),l.set(f.value,h.value)}return{status:n.value,value:l}})}else{const l=new Map;for(const c of s){const f=c.key,h=c.value;if(f.status==="aborted"||h.status==="aborted")return INVALID;(f.status==="dirty"||h.status==="dirty")&&n.dirty(),l.set(f.value,h.value)}return{status:n.value,value:l}}}}ZodMap.create=(a,e,n)=>new ZodMap({valueType:e,keyType:a,typeName:ZodFirstPartyTypeKind.ZodMap,...processCreateParams(n)});class ZodSet extends ZodType{_parse(e){const{status:n,ctx:t}=this._processInputParams(e);if(t.parsedType!==ZodParsedType.set)return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.set,received:t.parsedType}),INVALID;const r=this._def;r.minSize!==null&&t.data.size<r.minSize.value&&(addIssueToContext(t,{code:ZodIssueCode.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),n.dirty()),r.maxSize!==null&&t.data.size>r.maxSize.value&&(addIssueToContext(t,{code:ZodIssueCode.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),n.dirty());const o=this._def.valueType;function s(c){const f=new Set;for(const h of c){if(h.status==="aborted")return INVALID;h.status==="dirty"&&n.dirty(),f.add(h.value)}return{status:n.value,value:f}}const l=[...t.data.values()].map((c,f)=>o._parse(new ParseInputLazyPath(t,c,t.path,f)));return t.common.async?Promise.all(l).then(c=>s(c)):s(l)}min(e,n){return new ZodSet({...this._def,minSize:{value:e,message:errorUtil.toString(n)}})}max(e,n){return new ZodSet({...this._def,maxSize:{value:e,message:errorUtil.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}ZodSet.create=(a,e)=>new ZodSet({valueType:a,minSize:null,maxSize:null,typeName:ZodFirstPartyTypeKind.ZodSet,...processCreateParams(e)});class ZodFunction extends ZodType{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==ZodParsedType.function)return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.function,received:n.parsedType}),INVALID;function t(l,c){return makeIssue({data:l,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,getErrorMap(),errorMap].filter(f=>!!f),issueData:{code:ZodIssueCode.invalid_arguments,argumentsError:c}})}function r(l,c){return makeIssue({data:l,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,getErrorMap(),errorMap].filter(f=>!!f),issueData:{code:ZodIssueCode.invalid_return_type,returnTypeError:c}})}const o={errorMap:n.common.contextualErrorMap},s=n.data;if(this._def.returns instanceof ZodPromise){const l=this;return OK(async function(...c){const f=new ZodError([]),h=await l._def.args.parseAsync(c,o).catch(d=>{throw f.addIssue(t(c,d)),f}),u=await Reflect.apply(s,this,h);return await l._def.returns._def.type.parseAsync(u,o).catch(d=>{throw f.addIssue(r(u,d)),f})})}else{const l=this;return OK(function(...c){const f=l._def.args.safeParse(c,o);if(!f.success)throw new ZodError([t(c,f.error)]);const h=Reflect.apply(s,this,f.data),u=l._def.returns.safeParse(h,o);if(!u.success)throw new ZodError([r(h,u.error)]);return u.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ZodFunction({...this._def,args:ZodTuple.create(e).rest(ZodUnknown.create())})}returns(e){return new ZodFunction({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,t){return new ZodFunction({args:e||ZodTuple.create([]).rest(ZodUnknown.create()),returns:n||ZodUnknown.create(),typeName:ZodFirstPartyTypeKind.ZodFunction,...processCreateParams(t)})}}class ZodLazy extends ZodType{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}ZodLazy.create=(a,e)=>new ZodLazy({getter:a,typeName:ZodFirstPartyTypeKind.ZodLazy,...processCreateParams(e)});class ZodLiteral extends ZodType{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return addIssueToContext(n,{received:n.data,code:ZodIssueCode.invalid_literal,expected:this._def.value}),INVALID}return{status:"valid",value:e.data}}get value(){return this._def.value}}ZodLiteral.create=(a,e)=>new ZodLiteral({value:a,typeName:ZodFirstPartyTypeKind.ZodLiteral,...processCreateParams(e)});function createZodEnum(a,e){return new ZodEnum({values:a,typeName:ZodFirstPartyTypeKind.ZodEnum,...processCreateParams(e)})}class ZodEnum extends ZodType{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),t=this._def.values;return addIssueToContext(n,{expected:util.joinValues(t),received:n.parsedType,code:ZodIssueCode.invalid_type}),INVALID}if(this._def.values.indexOf(e.data)===-1){const n=this._getOrReturnCtx(e),t=this._def.values;return addIssueToContext(n,{received:n.data,code:ZodIssueCode.invalid_enum_value,options:t}),INVALID}return OK(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e){return ZodEnum.create(e)}exclude(e){return ZodEnum.create(this.options.filter(n=>!e.includes(n)))}}ZodEnum.create=createZodEnum;class ZodNativeEnum extends ZodType{_parse(e){const n=util.getValidEnumValues(this._def.values),t=this._getOrReturnCtx(e);if(t.parsedType!==ZodParsedType.string&&t.parsedType!==ZodParsedType.number){const r=util.objectValues(n);return addIssueToContext(t,{expected:util.joinValues(r),received:t.parsedType,code:ZodIssueCode.invalid_type}),INVALID}if(n.indexOf(e.data)===-1){const r=util.objectValues(n);return addIssueToContext(t,{received:t.data,code:ZodIssueCode.invalid_enum_value,options:r}),INVALID}return OK(e.data)}get enum(){return this._def.values}}ZodNativeEnum.create=(a,e)=>new ZodNativeEnum({values:a,typeName:ZodFirstPartyTypeKind.ZodNativeEnum,...processCreateParams(e)});class ZodPromise extends ZodType{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==ZodParsedType.promise&&n.common.async===!1)return addIssueToContext(n,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.promise,received:n.parsedType}),INVALID;const t=n.parsedType===ZodParsedType.promise?n.data:Promise.resolve(n.data);return OK(t.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}ZodPromise.create=(a,e)=>new ZodPromise({type:a,typeName:ZodFirstPartyTypeKind.ZodPromise,...processCreateParams(e)});class ZodEffects extends ZodType{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ZodFirstPartyTypeKind.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:t}=this._processInputParams(e),r=this._def.effect||null,o={addIssue:s=>{addIssueToContext(t,s),s.fatal?n.abort():n.dirty()},get path(){return t.path}};if(o.addIssue=o.addIssue.bind(o),r.type==="preprocess"){const s=r.transform(t.data,o);return t.common.issues.length?{status:"dirty",value:t.data}:t.common.async?Promise.resolve(s).then(l=>this._def.schema._parseAsync({data:l,path:t.path,parent:t})):this._def.schema._parseSync({data:s,path:t.path,parent:t})}if(r.type==="refinement"){const s=l=>{const c=r.refinement(l,o);if(t.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l};if(t.common.async===!1){const l=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});return l.status==="aborted"?INVALID:(l.status==="dirty"&&n.dirty(),s(l.value),{status:n.value,value:l.value})}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then(l=>l.status==="aborted"?INVALID:(l.status==="dirty"&&n.dirty(),s(l.value).then(()=>({status:n.value,value:l.value}))))}if(r.type==="transform")if(t.common.async===!1){const s=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});if(!isValid(s))return s;const l=r.transform(s.value,o);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:l}}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then(s=>isValid(s)?Promise.resolve(r.transform(s.value,o)).then(l=>({status:n.value,value:l})):s);util.assertNever(r)}}ZodEffects.create=(a,e,n)=>new ZodEffects({schema:a,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:e,...processCreateParams(n)});ZodEffects.createWithPreprocess=(a,e,n)=>new ZodEffects({schema:e,effect:{type:"preprocess",transform:a},typeName:ZodFirstPartyTypeKind.ZodEffects,...processCreateParams(n)});class ZodOptional extends ZodType{_parse(e){return this._getType(e)===ZodParsedType.undefined?OK(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ZodOptional.create=(a,e)=>new ZodOptional({innerType:a,typeName:ZodFirstPartyTypeKind.ZodOptional,...processCreateParams(e)});class ZodNullable extends ZodType{_parse(e){return this._getType(e)===ZodParsedType.null?OK(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ZodNullable.create=(a,e)=>new ZodNullable({innerType:a,typeName:ZodFirstPartyTypeKind.ZodNullable,...processCreateParams(e)});class ZodDefault extends ZodType{_parse(e){const{ctx:n}=this._processInputParams(e);let t=n.data;return n.parsedType===ZodParsedType.undefined&&(t=this._def.defaultValue()),this._def.innerType._parse({data:t,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}ZodDefault.create=(a,e)=>new ZodDefault({innerType:a,typeName:ZodFirstPartyTypeKind.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...processCreateParams(e)});class ZodCatch extends ZodType{_parse(e){const{ctx:n}=this._processInputParams(e),t={...n,common:{...n.common,issues:[]}},r=this._def.innerType._parse({data:t.data,path:t.path,parent:{...t}});return isAsync(r)?r.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new ZodError(t.common.issues)},input:t.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new ZodError(t.common.issues)},input:t.data})}}removeCatch(){return this._def.innerType}}ZodCatch.create=(a,e)=>new ZodCatch({innerType:a,typeName:ZodFirstPartyTypeKind.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...processCreateParams(e)});class ZodNaN extends ZodType{_parse(e){if(this._getType(e)!==ZodParsedType.nan){const t=this._getOrReturnCtx(e);return addIssueToContext(t,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.nan,received:t.parsedType}),INVALID}return{status:"valid",value:e.data}}}ZodNaN.create=a=>new ZodNaN({typeName:ZodFirstPartyTypeKind.ZodNaN,...processCreateParams(a)});const BRAND=Symbol("zod_brand");class ZodBranded extends ZodType{_parse(e){const{ctx:n}=this._processInputParams(e),t=n.data;return this._def.type._parse({data:t,path:n.path,parent:n})}unwrap(){return this._def.type}}class ZodPipeline extends ZodType{_parse(e){const{status:n,ctx:t}=this._processInputParams(e);if(t.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:t.data,path:t.path,parent:t});return o.status==="aborted"?INVALID:o.status==="dirty"?(n.dirty(),DIRTY(o.value)):this._def.out._parseAsync({data:o.value,path:t.path,parent:t})})();{const r=this._def.in._parseSync({data:t.data,path:t.path,parent:t});return r.status==="aborted"?INVALID:r.status==="dirty"?(n.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:t.path,parent:t})}}static create(e,n){return new ZodPipeline({in:e,out:n,typeName:ZodFirstPartyTypeKind.ZodPipeline})}}class ZodReadonly extends ZodType{_parse(e){const n=this._def.innerType._parse(e);return isValid(n)&&(n.value=Object.freeze(n.value)),n}}ZodReadonly.create=(a,e)=>new ZodReadonly({innerType:a,typeName:ZodFirstPartyTypeKind.ZodReadonly,...processCreateParams(e)});const custom=(a,e={},n)=>a?ZodAny.create().superRefine((t,r)=>{var o,s;if(!a(t)){const l=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e,c=(s=(o=l.fatal)!==null&&o!==void 0?o:n)!==null&&s!==void 0?s:!0,f=typeof l=="string"?{message:l}:l;r.addIssue({code:"custom",...f,fatal:c})}}):ZodAny.create(),late={object:ZodObject.lazycreate};var ZodFirstPartyTypeKind;(function(a){a.ZodString="ZodString",a.ZodNumber="ZodNumber",a.ZodNaN="ZodNaN",a.ZodBigInt="ZodBigInt",a.ZodBoolean="ZodBoolean",a.ZodDate="ZodDate",a.ZodSymbol="ZodSymbol",a.ZodUndefined="ZodUndefined",a.ZodNull="ZodNull",a.ZodAny="ZodAny",a.ZodUnknown="ZodUnknown",a.ZodNever="ZodNever",a.ZodVoid="ZodVoid",a.ZodArray="ZodArray",a.ZodObject="ZodObject",a.ZodUnion="ZodUnion",a.ZodDiscriminatedUnion="ZodDiscriminatedUnion",a.ZodIntersection="ZodIntersection",a.ZodTuple="ZodTuple",a.ZodRecord="ZodRecord",a.ZodMap="ZodMap",a.ZodSet="ZodSet",a.ZodFunction="ZodFunction",a.ZodLazy="ZodLazy",a.ZodLiteral="ZodLiteral",a.ZodEnum="ZodEnum",a.ZodEffects="ZodEffects",a.ZodNativeEnum="ZodNativeEnum",a.ZodOptional="ZodOptional",a.ZodNullable="ZodNullable",a.ZodDefault="ZodDefault",a.ZodCatch="ZodCatch",a.ZodPromise="ZodPromise",a.ZodBranded="ZodBranded",a.ZodPipeline="ZodPipeline",a.ZodReadonly="ZodReadonly"})(ZodFirstPartyTypeKind||(ZodFirstPartyTypeKind={}));const instanceOfType=(a,e={message:`Input not instance of ${a.name}`})=>custom(n=>n instanceof a,e),stringType=ZodString.create,numberType=ZodNumber.create,nanType=ZodNaN.create,bigIntType=ZodBigInt.create,booleanType=ZodBoolean.create,dateType=ZodDate.create,symbolType=ZodSymbol.create,undefinedType=ZodUndefined.create,nullType=ZodNull.create,anyType=ZodAny.create,unknownType=ZodUnknown.create,neverType=ZodNever.create,voidType=ZodVoid.create,arrayType=ZodArray.create,objectType=ZodObject.create,strictObjectType=ZodObject.strictCreate,unionType=ZodUnion.create,discriminatedUnionType=ZodDiscriminatedUnion.create,intersectionType=ZodIntersection.create,tupleType=ZodTuple.create,recordType=ZodRecord.create,mapType=ZodMap.create,setType=ZodSet.create,functionType=ZodFunction.create,lazyType=ZodLazy.create,literalType=ZodLiteral.create,enumType=ZodEnum.create,nativeEnumType=ZodNativeEnum.create,promiseType=ZodPromise.create,effectsType=ZodEffects.create,optionalType=ZodOptional.create,nullableType=ZodNullable.create,preprocessType=ZodEffects.createWithPreprocess,pipelineType=ZodPipeline.create,ostring=()=>stringType().optional(),onumber=()=>numberType().optional(),oboolean=()=>booleanType().optional(),coerce={string:a=>ZodString.create({...a,coerce:!0}),number:a=>ZodNumber.create({...a,coerce:!0}),boolean:a=>ZodBoolean.create({...a,coerce:!0}),bigint:a=>ZodBigInt.create({...a,coerce:!0}),date:a=>ZodDate.create({...a,coerce:!0})},NEVER=INVALID;var z=Object.freeze({__proto__:null,defaultErrorMap:errorMap,setErrorMap,getErrorMap,makeIssue,EMPTY_PATH,addIssueToContext,ParseStatus,INVALID,DIRTY,OK,isAborted,isDirty,isValid,isAsync,get util(){return util},get objectUtil(){return objectUtil},ZodParsedType,getParsedType,ZodType,ZodString,ZodNumber,ZodBigInt,ZodBoolean,ZodDate,ZodSymbol,ZodUndefined,ZodNull,ZodAny,ZodUnknown,ZodNever,ZodVoid,ZodArray,ZodObject,ZodUnion,ZodDiscriminatedUnion,ZodIntersection,ZodTuple,ZodRecord,ZodMap,ZodSet,ZodFunction,ZodLazy,ZodLiteral,ZodEnum,ZodNativeEnum,ZodPromise,ZodEffects,ZodTransformer:ZodEffects,ZodOptional,ZodNullable,ZodDefault,ZodCatch,ZodNaN,BRAND,ZodBranded,ZodPipeline,ZodReadonly,custom,Schema:ZodType,ZodSchema:ZodType,late,get ZodFirstPartyTypeKind(){return ZodFirstPartyTypeKind},coerce,any:anyType,array:arrayType,bigint:bigIntType,boolean:booleanType,date:dateType,discriminatedUnion:discriminatedUnionType,effect:effectsType,enum:enumType,function:functionType,instanceof:instanceOfType,intersection:intersectionType,lazy:lazyType,literal:literalType,map:mapType,nan:nanType,nativeEnum:nativeEnumType,never:neverType,null:nullType,nullable:nullableType,number:numberType,object:objectType,oboolean,onumber,optional:optionalType,ostring,pipeline:pipelineType,preprocess:preprocessType,promise:promiseType,record:recordType,set:setType,strictObject:strictObjectType,string:stringType,symbol:symbolType,transformer:effectsType,tuple:tupleType,undefined:undefinedType,union:unionType,unknown:unknownType,void:voidType,NEVER,ZodIssueCode,quotelessJson,ZodError});const listInputSchema=z.object({name:z.string(),label:z.string(),type:z.literal("list"),required:z.boolean().optional(),options:z.array(z.object({value:z.string(),label:z.string()}))}),otherInputSchema=z.object({name:z.string(),label:z.string(),type:z.enum(["int","float","bool","str"]),required:z.boolean().optional()}),createObjectInputsSchema=z.array(z.union([listInputSchema,otherInputSchema])),mapInputsToValueType=a=>a.reduce((e,n)=>{var t;return n.dtype==="str"||n.dtype==="list"?e[n.name]=z.string():n.dtype==="int"||n.dtype==="float"?e[n.name]=z.number():e[n.name]=z.boolean(),n.required||(e[n.name]=(t=e[n.name])==null?void 0:t.optional()),e},{}),createSchemaFromFeatures=a=>z.object(mapInputsToValueType(a)),createFeature=a=>createObjectInputsSchema.parse(Object.values(a).map(n=>({...n,type:n.dtype,required:!1,label:n.name}))).map(n=>{var r;const t=(r=a[n.name])==null?void 0:r.value;return n.type==="list"?{...n,options:n.options,value:t}:{...n,value:t}}),mapShapeInputsToFeatures=(a,e)=>Object.entries(a).reduce((n,[t,r])=>{var o;return n[t]={name:t,dtype:(o=e.find(s=>s.name===t))==null?void 0:o.type,value:r},n},{}),addNewInput=(a,e,n,t)=>{a&&(e==="objects"||e==="main")&&(a[e][n]?a[e][n].values.includes(t)||a[e][n].values.push(t):a[e][n]={restricted:!1,values:[t]})},mapFeatureList=(a={restricted:!1,values:[]})=>(a.values??(a.values=[]),a.restricted??(a.restricted=!1),a.values.sort((e,n)=>e.localeCompare(n)).map(e=>({value:e,label:e})));function create_if_block_3$6(a){let e,n=a[0].value+"",t;return{c(){e=element("p"),t=text(n),this.h()},l(r){e=claim_element(r,"P",{class:!0});var o=children(e);t=claim_text(o,n),o.forEach(detach),this.h()},h(){attr(e,"class","first-letter:uppercase")},m(r,o){insert_hydration(r,e,o),append_hydration(e,t)},p(r,o){o&1&&n!==(n=r[0].value+"")&&set_data(t,n)},i:noop,o:noop,d(r){r&&detach(e)}}}function create_if_block$o(a){let e,n,t,r,o;const s=[create_if_block_2$9,create_else_block$7],l=[];function c(h,u){return h[0].type==="str"?0:1}e=c(a),n=l[e]=s[e](a);let f=a[3]&&create_if_block_1$e();return{c(){n.c(),t=space(),f&&f.c(),r=empty()},l(h){n.l(h),t=claim_space(h),f&&f.l(h),r=empty()},m(h,u){l[e].m(h,u),insert_hydration(h,t,u),f&&f.m(h,u),insert_hydration(h,r,u),o=!0},p(h,u){let i=e;e=c(h),e===i?l[e].p(h,u):(group_outros(),transition_out(l[i],1,1,()=>{l[i]=null}),check_outros(),n=l[e],n?n.p(h,u):(n=l[e]=s[e](h),n.c()),transition_in(n,1),n.m(t.parentNode,t)),h[3]?f?u&8&&transition_in(f,1):(f=create_if_block_1$e(),f.c(),transition_in(f,1),f.m(r.parentNode,r)):f&&(group_outros(),transition_out(f,1,1,()=>{f=null}),check_outros())},i(h){o||(transition_in(n),transition_in(f),o=!0)},o(h){transition_out(n),transition_out(f),o=!1},d(h){h&&(detach(t),detach(r)),l[e].d(h),f&&f.d(h)}}}function create_else_block$7(a){let e,n;return e=new Input({props:{value:a[0].value,type:"number",step:a[0].type==="int"?"1":"any"}}),e.$on("change",a[8]),e.$on("input",a[9]),e.$on("keyup",keyup_handler$1),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r&1&&(o.value=t[0].value),r&1&&(o.step=t[0].type==="int"?"1":"any"),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_if_block_2$9(a){var t,r,o;let e,n;return e=new AutoCompleteFeatureInput({props:{value:a[0].value,onTextInputChange:a[7],featureList:mapFeatureList((t=a[4].featuresList)==null?void 0:t[a[2]][a[0].name]),isInputEnabled:!((o=(r=a[4].featuresList)==null?void 0:r[a[2]][a[0].name])!=null&&o.restricted)}}),{c(){create_component(e.$$.fragment)},l(s){claim_component(e.$$.fragment,s)},m(s,l){mount_component(e,s,l),n=!0},p(s,l){var f,h,u;const c={};l&1&&(c.value=s[0].value),l&1&&(c.onTextInputChange=s[7]),l&21&&(c.featureList=mapFeatureList((f=s[4].featuresList)==null?void 0:f[s[2]][s[0].name])),l&21&&(c.isInputEnabled=!((u=(h=s[4].featuresList)==null?void 0:h[s[2]][s[0].name])!=null&&u.restricted)),e.$set(c)},i(s){n||(transition_in(e.$$.fragment,s),n=!0)},o(s){transition_out(e.$$.fragment,s),n=!1},d(s){destroy_component(e,s)}}}function create_if_block_1$e(a){let e,n,t;return n=new Check_check({}),{c(){e=element("span"),create_component(n.$$.fragment),this.h()},l(r){e=claim_element(r,"SPAN",{class:!0});var o=children(e);claim_component(n.$$.fragment,o),o.forEach(detach),this.h()},h(){attr(e,"class","text-green-700")},m(r,o){insert_hydration(r,e,o),mount_component(n,e,null),t=!0},i(r){t||(transition_in(n.$$.fragment,r),t=!0)},o(r){transition_out(n.$$.fragment,r),t=!1},d(r){r&&detach(e),destroy_component(n)}}}function create_fragment$z(a){let e,n,t,r;const o=[create_if_block$o,create_if_block_3$6],s=[];function l(c,f){return c[1]?0:c[0].value||c[0].value===0?1:-1}return~(n=l(a))&&(t=s[n]=o[n](a)),{c(){e=element("div"),t&&t.c(),this.h()},l(c){e=claim_element(c,"DIV",{class:!0});var f=children(e);t&&t.l(f),f.forEach(detach),this.h()},h(){attr(e,"class","flex justify-start items-center gap-4")},m(c,f){insert_hydration(c,e,f),~n&&s[n].m(e,null),r=!0},p(c,[f]){let h=n;n=l(c),n===h?~n&&s[n].p(c,f):(t&&(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros()),~n?(t=s[n],t?t.p(c,f):(t=s[n]=o[n](c),t.c()),transition_in(t,1),t.m(e,null)):t=null)},i(c){r||(transition_in(t),r=!0)},o(c){transition_out(t),r=!1},d(c){c&&detach(e),~n&&s[n].d()}}}const keyup_handler$1=a=>a.stopPropagation();function instance$E(a,e,n){let t;component_subscribe(a,itemMetas,d=>n(4,t=d));let{feature:r}=e,{isEditing:o}=e,{saveInputChange:s}=e,{featureClass:l}=e,c=!1;const f=(d,p)=>{let _=d;r.type==="int"?_=Math.round(Number(d)):r.type==="float"&&(_=Number(d)),typeof _=="string"&&addNewInput(t.featuresList,l,p,_),s(_,p),n(3,c=!0)},h=d=>f(d,r.name),u=d=>f(d.currentTarget.value,r.name),i=()=>n(3,c=!1);return a.$$set=d=>{"feature"in d&&n(0,r=d.feature),"isEditing"in d&&n(1,o=d.isEditing),"saveInputChange"in d&&n(6,s=d.saveInputChange),"featureClass"in d&&n(2,l=d.featureClass)},[r,o,l,c,t,f,s,h,u,i]}class TextFeatureInput extends SvelteComponent{constructor(e){super(),init(this,e,instance$E,create_fragment$z,safe_not_equal,{feature:0,isEditing:1,saveInputChange:6,featureClass:2})}}function create_if_block_1$d(a){let e,n=a[0].value+"",t;return{c(){e=element("p"),t=text(n),this.h()},l(r){e=claim_element(r,"P",{class:!0});var o=children(e);t=claim_text(o,n),o.forEach(detach),this.h()},h(){attr(e,"class","first-letter:uppercase")},m(r,o){insert_hydration(r,e,o),append_hydration(e,t)},p(r,o){o&1&&n!==(n=r[0].value+"")&&set_data(t,n)},i:noop,o:noop,d(r){r&&detach(e)}}}function create_if_block$n(a){let e,n;return e=new Combobox({props:{placeholder:`Select a ${a[0].name}`,listItems:a[0].options,saveValue:a[3],value:a[0].value}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r&1&&(o.placeholder=`Select a ${t[0].name}`),r&1&&(o.listItems=t[0].options),r&5&&(o.saveValue=t[3]),r&1&&(o.value=t[0].value),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_fragment$y(a){let e,n,t,r;const o=[create_if_block$n,create_if_block_1$d],s=[];function l(c,f){return c[1]?0:c[0].value?1:-1}return~(e=l(a))&&(n=s[e]=o[e](a)),{c(){n&&n.c(),t=empty()},l(c){n&&n.l(c),t=empty()},m(c,f){~e&&s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){let h=e;e=l(c),e===h?~e&&s[e].p(c,f):(n&&(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros()),~e?(n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t)):n=null)},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),~e&&s[e].d(c)}}}function instance$D(a,e,n){let{listFeature:t}=e,{isEditing:r}=e,{handleInputChange:o}=e;const s=l=>o(l,t.name);return a.$$set=l=>{"listFeature"in l&&n(0,t=l.listFeature),"isEditing"in l&&n(1,r=l.isEditing),"handleInputChange"in l&&n(2,o=l.handleInputChange)},[t,r,o,s]}class SelectFeatureInput extends SvelteComponent{constructor(e){super(),init(this,e,instance$D,create_fragment$y,safe_not_equal,{listFeature:0,isEditing:1,handleInputChange:2})}}function get_each_context$9(a,e,n){const t=a.slice();return t[6]=e[n],t}function create_if_block_3$5(a){let e,n=a[6].label.replace("_"," ")+"",t;return{c(){e=element("p"),t=text(n),this.h()},l(r){e=claim_element(r,"P",{class:!0});var o=children(e);t=claim_text(o,n),o.forEach(detach),this.h()},h(){attr(e,"class","font-medium first-letter:uppercase flex items-center")},m(r,o){insert_hydration(r,e,o),append_hydration(e,t)},p(r,o){o&1&&n!==(n=r[6].label.replace("_"," ")+"")&&set_data(t,n)},d(r){r&&detach(e)}}}function create_if_block_2$8(a){let e,n;function t(...r){return a[4](a[6],...r)}return e=new Checkbox({props:{checked:!!a[6].value,disabled:!a[2],handleClick:t}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,o){mount_component(e,r,o),n=!0},p(r,o){a=r;const s={};o&1&&(s.checked=!!a[6].value),o&4&&(s.disabled=!a[2]),o&9&&(s.handleClick=t),e.$set(s)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_if_block_1$c(a){let e,n;return e=new SelectFeatureInput({props:{isEditing:a[2],handleInputChange:a[5],listFeature:{value:a[6].value,name:a[6].name,options:a[6].options}}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r&4&&(o.isEditing=t[2]),r&8&&(o.handleInputChange=t[5]),r&1&&(o.listFeature={value:t[6].value,name:t[6].name,options:t[6].options}),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_if_block$m(a){let e,n;return e=new TextFeatureInput({props:{featureClass:a[1],feature:a[6],saveInputChange:a[3],isEditing:a[2]}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r&2&&(o.featureClass=t[1]),r&1&&(o.feature=t[6]),r&8&&(o.saveInputChange=t[3]),r&4&&(o.isEditing=t[2]),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_each_block$9(a){let e,n,t,r,o,s,l=(a[2]||a[6].value!==void 0)&&create_if_block_3$5(a),c=a[6].type==="bool"&&(a[6].value!==void 0||a[2])&&create_if_block_2$8(a),f=a[6].type==="list"&&create_if_block_1$c(a),h=(a[6].type==="str"||a[6].type==="int"||a[6].type==="float")&&create_if_block$m(a);return{c(){e=element("div"),l&&l.c(),n=space(),c&&c.c(),t=space(),f&&f.c(),r=space(),h&&h.c(),o=space(),this.h()},l(u){e=claim_element(u,"DIV",{class:!0});var i=children(e);l&&l.l(i),n=claim_space(i),c&&c.l(i),t=claim_space(i),f&&f.l(i),r=claim_space(i),h&&h.l(i),o=claim_space(i),i.forEach(detach),this.h()},h(){attr(e,"class","grid gap-4 grid-cols-[150px_auto] mt-2 pr-4")},m(u,i){insert_hydration(u,e,i),l&&l.m(e,null),append_hydration(e,n),c&&c.m(e,null),append_hydration(e,t),f&&f.m(e,null),append_hydration(e,r),h&&h.m(e,null),append_hydration(e,o),s=!0},p(u,i){u[2]||u[6].value!==void 0?l?l.p(u,i):(l=create_if_block_3$5(u),l.c(),l.m(e,n)):l&&(l.d(1),l=null),u[6].type==="bool"&&(u[6].value!==void 0||u[2])?c?(c.p(u,i),i&5&&transition_in(c,1)):(c=create_if_block_2$8(u),c.c(),transition_in(c,1),c.m(e,t)):c&&(group_outros(),transition_out(c,1,1,()=>{c=null}),check_outros()),u[6].type==="list"?f?(f.p(u,i),i&1&&transition_in(f,1)):(f=create_if_block_1$c(u),f.c(),transition_in(f,1),f.m(e,r)):f&&(group_outros(),transition_out(f,1,1,()=>{f=null}),check_outros()),u[6].type==="str"||u[6].type==="int"||u[6].type==="float"?h?(h.p(u,i),i&1&&transition_in(h,1)):(h=create_if_block$m(u),h.c(),transition_in(h,1),h.m(e,o)):h&&(group_outros(),transition_out(h,1,1,()=>{h=null}),check_outros())},i(u){s||(transition_in(c),transition_in(f),transition_in(h),s=!0)},o(u){transition_out(c),transition_out(f),transition_out(h),s=!1},d(u){u&&detach(e),l&&l.d(),c&&c.d(),f&&f.d(),h&&h.d()}}}function create_fragment$x(a){let e,n,t=ensure_array_like(a[0]),r=[];for(let s=0;s<t.length;s+=1)r[s]=create_each_block$9(get_each_context$9(a,t,s));const o=s=>transition_out(r[s],1,1,()=>{r[s]=null});return{c(){for(let s=0;s<r.length;s+=1)r[s].c();e=empty()},l(s){for(let l=0;l<r.length;l+=1)r[l].l(s);e=empty()},m(s,l){for(let c=0;c<r.length;c+=1)r[c]&&r[c].m(s,l);insert_hydration(s,e,l),n=!0},p(s,[l]){if(l&15){t=ensure_array_like(s[0]);let c;for(c=0;c<t.length;c+=1){const f=get_each_context$9(s,t,c);r[c]?(r[c].p(f,l),transition_in(r[c],1)):(r[c]=create_each_block$9(f),r[c].c(),transition_in(r[c],1),r[c].m(e.parentNode,e))}for(group_outros(),c=t.length;c<r.length;c+=1)o(c);check_outros()}},i(s){if(!n){for(let l=0;l<t.length;l+=1)transition_in(r[l]);n=!0}},o(s){r=r.filter(Boolean);for(let l=0;l<r.length;l+=1)transition_out(r[l]);n=!1},d(s){s&&detach(e),destroy_each(r,s)}}}function instance$C(a,e,n){let{features:t}=e,{featureClass:r}=e,{isEditing:o}=e,{saveInputChange:s}=e;const l=(f,h)=>s(h,f.name),c=(f,h)=>s(f,h);return a.$$set=f=>{"features"in f&&n(0,t=f.features),"featureClass"in f&&n(1,r=f.featureClass),"isEditing"in f&&n(2,o=f.isEditing),"saveInputChange"in f&&n(3,s=f.saveInputChange)},[t,r,o,s,l,c]}class UpdateFeatureInputs extends SvelteComponent{constructor(e){super(),init(this,e,instance$C,create_fragment$x,safe_not_equal,{features:0,featureClass:1,isEditing:2,saveInputChange:3})}}function get_each_context$8(a,e,n){const t=a.slice();return t[5]=e[n],t}function create_default_slot$g(a){let e,n;return e=new Pencil({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p:noop,i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_each_block$8(a){let e,n=a[5].id+"",t,r,o,s,l,c="File name",f,h,u=a[5].fileName+"",i,d,p,_,m,g="Width",b,v,T=a[5].width+"",y,w,S,O,P="Height",E,A,$=a[5].height+"",k,D,I,C,L="Format",K,G,J=a[5].format+"",Y,te;return{c(){e=element("h3"),t=text(n),r=space(),o=element("div"),s=element("div"),l=element("p"),l.textContent=c,f=space(),h=element("p"),i=text(u),p=space(),_=element("div"),m=element("p"),m.textContent=g,b=space(),v=element("p"),y=text(T),w=space(),S=element("div"),O=element("p"),O.textContent=P,E=space(),A=element("p"),k=text($),D=space(),I=element("div"),C=element("p"),C.textContent=L,K=space(),G=element("p"),Y=text(J),te=space(),this.h()},l(ee){e=claim_element(ee,"H3",{class:!0});var ie=children(e);t=claim_text(ie,n),ie.forEach(detach),r=claim_space(ee),o=claim_element(ee,"DIV",{class:!0});var ae=children(o);s=claim_element(ae,"DIV",{class:!0});var ue=children(s);l=claim_element(ue,"P",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(l)!=="svelte-26li1s"&&(l.textContent=c),f=claim_space(ue),h=claim_element(ue,"P",{class:!0,title:!0});var fe=children(h);i=claim_text(fe,u),fe.forEach(detach),ue.forEach(detach),p=claim_space(ae),_=claim_element(ae,"DIV",{class:!0});var ge=children(_);m=claim_element(ge,"P",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(m)!=="svelte-uc7myb"&&(m.textContent=g),b=claim_space(ge),v=claim_element(ge,"P",{});var be=children(v);y=claim_text(be,T),be.forEach(detach),ge.forEach(detach),w=claim_space(ae),S=claim_element(ae,"DIV",{class:!0});var xe=children(S);O=claim_element(xe,"P",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(O)!=="svelte-zdyg3w"&&(O.textContent=P),E=claim_space(xe),A=claim_element(xe,"P",{});var ve=children(A);k=claim_text(ve,$),ve.forEach(detach),xe.forEach(detach),D=claim_space(ae),I=claim_element(ae,"DIV",{class:!0});var Te=children(I);C=claim_element(Te,"P",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(C)!=="svelte-1dszlb8"&&(C.textContent=L),K=claim_space(Te),G=claim_element(Te,"P",{});var pe=children(G);Y=claim_text(pe,J),pe.forEach(detach),Te.forEach(detach),te=claim_space(ae),ae.forEach(detach),this.h()},h(){attr(e,"class","uppercase font-medium h-10 flex items-center"),attr(l,"class","font-medium first-letter:uppercase"),attr(h,"class","truncate"),attr(h,"title",d=a[5].fileName),attr(s,"class","grid gap-4 grid-cols-[150px_auto] mt-2"),attr(m,"class","font-medium first-letter:uppercase"),attr(_,"class","grid gap-4 grid-cols-[150px_auto] mt-2"),attr(O,"class","font-medium first-letter:uppercase"),attr(S,"class","grid gap-4 grid-cols-[150px_auto] mt-2"),attr(C,"class","font-medium first-letter:uppercase"),attr(I,"class","grid gap-4 grid-cols-[150px_auto] mt-2"),attr(o,"class","mx-4 mb-4")},m(ee,ie){insert_hydration(ee,e,ie),append_hydration(e,t),insert_hydration(ee,r,ie),insert_hydration(ee,o,ie),append_hydration(o,s),append_hydration(s,l),append_hydration(s,f),append_hydration(s,h),append_hydration(h,i),append_hydration(o,p),append_hydration(o,_),append_hydration(_,m),append_hydration(_,b),append_hydration(_,v),append_hydration(v,y),append_hydration(o,w),append_hydration(o,S),append_hydration(S,O),append_hydration(S,E),append_hydration(S,A),append_hydration(A,k),append_hydration(o,D),append_hydration(o,I),append_hydration(I,C),append_hydration(I,K),append_hydration(I,G),append_hydration(G,Y),append_hydration(o,te)},p(ee,ie){ie&2&&n!==(n=ee[5].id+"")&&set_data(t,n),ie&2&&u!==(u=ee[5].fileName+"")&&set_data(i,u),ie&2&&d!==(d=ee[5].fileName)&&attr(h,"title",d),ie&2&&T!==(T=ee[5].width+"")&&set_data(y,T),ie&2&&$!==($=ee[5].height+"")&&set_data(k,$),ie&2&&J!==(J=ee[5].format+"")&&set_data(Y,J)},d(ee){ee&&(detach(e),detach(r),detach(o))}}}function create_fragment$w(a){let e,n,t,r="Features",o,s,l,c,f,h,u,i;s=new TooltipIconButton({props:{selected:a[2],tooltipContent:"Edit scene features",$$slots:{default:[create_default_slot$g]},$$scope:{ctx:a}}}),s.$on("click",a[3]),f=new UpdateFeatureInputs({props:{featureClass:"main",features:a[0],isEditing:a[2],saveInputChange:a[4]}});let d=ensure_array_like(a[1]),p=[];for(let _=0;_<d.length;_+=1)p[_]=create_each_block$8(get_each_context$8(a,d,_));return{c(){e=element("div"),n=element("h3"),t=element("span"),t.textContent=r,o=space(),create_component(s.$$.fragment),l=space(),c=element("div"),create_component(f.$$.fragment),h=space(),u=element("div");for(let _=0;_<p.length;_+=1)p[_].c();this.h()},l(_){e=claim_element(_,"DIV",{class:!0});var m=children(e);n=claim_element(m,"H3",{class:!0});var g=children(n);t=claim_element(g,"SPAN",{"data-svelte-h":!0}),get_svelte_dataset(t)!=="svelte-sapa9p"&&(t.textContent=r),o=claim_space(g),claim_component(s.$$.fragment,g),g.forEach(detach),l=claim_space(m),c=claim_element(m,"DIV",{class:!0});var b=children(c);claim_component(f.$$.fragment,b),b.forEach(detach),m.forEach(detach),h=claim_space(_),u=claim_element(_,"DIV",{class:!0});var v=children(u);for(let T=0;T<p.length;T+=1)p[T].l(v);v.forEach(detach),this.h()},h(){attr(n,"class","uppercase font-medium h-10"),attr(c,"class","mx-4"),attr(e,"class","border-b-2 border-b-slate-500 p-4 pb-8 text-slate-800"),attr(u,"class","p-4 text-slate-800")},m(_,m){insert_hydration(_,e,m),append_hydration(e,n),append_hydration(n,t),append_hydration(n,o),mount_component(s,n,null),append_hydration(e,l),append_hydration(e,c),mount_component(f,c,null),insert_hydration(_,h,m),insert_hydration(_,u,m);for(let g=0;g<p.length;g+=1)p[g]&&p[g].m(u,null);i=!0},p(_,[m]){const g={};m&4&&(g.selected=_[2]),m&256&&(g.$$scope={dirty:m,ctx:_}),s.$set(g);const b={};if(m&1&&(b.features=_[0]),m&4&&(b.isEditing=_[2]),f.$set(b),m&2){d=ensure_array_like(_[1]);let v;for(v=0;v<d.length;v+=1){const T=get_each_context$8(_,d,v);p[v]?p[v].p(T,m):(p[v]=create_each_block$8(T),p[v].c(),p[v].m(u,null))}for(;v<p.length;v+=1)p[v].d(1);p.length=d.length}},i(_){i||(transition_in(s.$$.fragment,_),transition_in(f.$$.fragment,_),i=!0)},o(_){transition_out(s.$$.fragment,_),transition_out(f.$$.fragment,_),i=!1},d(_){_&&(detach(e),detach(h),detach(u)),destroy_component(s),destroy_component(f),destroy_each(p,_)}}}function instance$B(a,e,n){let t,r=[],o=!1;return itemMetas.subscribe(c=>{n(1,r=Object.values(c.views).map(h=>{var i;const u=Array.isArray(h)?h[0]:h;return{fileName:u.uri.split("/").at(-1),width:u.features.width.value,height:u.features.height.value,format:(i=u.uri.split(".").at(-1))==null?void 0:i.toUpperCase(),id:u.id}}));const f=Object.values(c.mainFeatures).length?c.mainFeatures:defaultSceneFeatures;n(0,t=createFeature(f))}),[t,r,o,()=>{n(2,o=!o)},(c,f)=>{itemMetas.update(h=>{var i;const u={...h};return u.mainFeatures={...u.mainFeatures,[f]:{...((i=u.mainFeatures)==null?void 0:i[f])||defaultSceneFeatures[f],value:c}},u}),canSave.set(!0)}]}class SceneInspector extends SvelteComponent{constructor(e){super(),init(this,e,instance$B,create_fragment$w,safe_not_equal,{})}}/**
 * @copyright CEA
 * @author CEA
 * @license CECILL
 *
 * This software is a collaborative computer program whose purpose is to
 * generate and explore labeled data for computer vision applications.
 * This software is governed by the CeCILL-C license under French law and
 * abiding by the rules of distribution of free software. You can use,
 * modify and/ or redistribute the software under the terms of the CeCILL-C
 * license as circulated by CEA, CNRS and INRIA at the following URL
 *
 * http://www.cecill.info
 */const itemBoxBeingEdited=writable(),lastFrameIndex=writable();function create_else_block$6(a){let e,n;return e=new Eye_off({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_if_block_4$2(a){let e,n;return e=new Eye({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_default_slot_3$5(a){let e,n,t,r;const o=[create_if_block_4$2,create_else_block$6],s=[];function l(c,f){return c[7]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,f){let h=e;e=l(c),e!==h&&(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n||(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function create_if_block_3$4(a){let e,n,t,r;return e=new TooltipIconButton({props:{tooltipContent:"Edit object",selected:a[4],$$slots:{default:[create_default_slot_2$5]},$$scope:{ctx:a}}}),e.$on("click",a[13]),t=new TooltipIconButton({props:{tooltipContent:"Delete object",$$slots:{default:[create_default_slot_1$8]},$$scope:{ctx:a}}}),t.$on("click",a[10]),{c(){create_component(e.$$.fragment),n=space(),create_component(t.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(t.$$.fragment,o)},m(o,s){mount_component(e,o,s),insert_hydration(o,n,s),mount_component(t,o,s),r=!0},p(o,s){const l={};s&16&&(l.selected=o[4]),s&8388608&&(l.$$scope={dirty:s,ctx:o}),e.$set(l);const c={};s&8388608&&(c.$$scope={dirty:s,ctx:o}),t.$set(c)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(t.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(t.$$.fragment,o),r=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(t,o)}}}function create_default_slot_2$5(a){let e,n;return e=new Pencil({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p:noop,i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_default_slot_1$8(a){let e,n;return e=new Trash_2({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p:noop,i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_default_slot$f(a){let e,n;return e=new ChevronRight({props:{class:cn("transition",{"rotate-90":a[2]}),strokeWidth:1}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r&4&&(o.class=cn("transition",{"rotate-90":t[2]})),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_if_block$l(a){let e,n,t,r,o,s="display",l,c,f,h,u,i,d=a[0].bbox&&create_if_block_2$7(a),p=a[0].mask&&create_if_block_1$b(a);return u=new UpdateFeatureInputs({props:{featureClass:"objects",features:a[8],isEditing:a[4],saveInputChange:a[11]}}),{c(){e=element("div"),n=element("div"),t=element("div"),r=element("div"),o=element("p"),o.textContent=s,l=space(),c=element("div"),d&&d.c(),f=space(),p&&p.c(),h=space(),create_component(u.$$.fragment),this.h()},l(_){e=claim_element(_,"DIV",{class:!0});var m=children(e);n=claim_element(m,"DIV",{class:!0,style:!0});var g=children(n);t=claim_element(g,"DIV",{class:!0});var b=children(t);r=claim_element(b,"DIV",{});var v=children(r);o=claim_element(v,"P",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(o)!=="svelte-1t2n1td"&&(o.textContent=s),l=claim_space(v),c=claim_element(v,"DIV",{class:!0});var T=children(c);d&&d.l(T),f=claim_space(T),p&&p.l(T),T.forEach(detach),v.forEach(detach),h=claim_space(b),claim_component(u.$$.fragment,b),b.forEach(detach),g.forEach(detach),m.forEach(detach),this.h()},h(){attr(o,"class","font-medium first-letter:uppercase"),attr(c,"class","flex gap-4"),attr(t,"class","flex flex-col gap-2"),attr(n,"class","border-l-4 border-dashed border-red-400 pl-4 pb-4 pt-4 flex flex-col gap-4"),set_style(n,"border-color",a[1]),attr(e,"class","pl-5 border-b border-b-slate-600 text-slate-800 bg-white")},m(_,m){insert_hydration(_,e,m),append_hydration(e,n),append_hydration(n,t),append_hydration(t,r),append_hydration(r,o),append_hydration(r,l),append_hydration(r,c),d&&d.m(c,null),append_hydration(c,f),p&&p.m(c,null),append_hydration(t,h),mount_component(u,t,null),i=!0},p(_,m){_[0].bbox?d?(d.p(_,m),m&1&&transition_in(d,1)):(d=create_if_block_2$7(_),d.c(),transition_in(d,1),d.m(c,f)):d&&(group_outros(),transition_out(d,1,1,()=>{d=null}),check_outros()),_[0].mask?p?(p.p(_,m),m&1&&transition_in(p,1)):(p=create_if_block_1$b(_),p.c(),transition_in(p,1),p.m(c,null)):p&&(group_outros(),transition_out(p,1,1,()=>{p=null}),check_outros());const g={};m&256&&(g.features=_[8]),m&16&&(g.isEditing=_[4]),u.$set(g),(!i||m&2)&&set_style(n,"border-color",_[1])},i(_){i||(transition_in(d),transition_in(p),transition_in(u.$$.fragment,_),i=!0)},o(_){transition_out(d),transition_out(p),transition_out(u.$$.fragment,_),i=!1},d(_){_&&detach(e),d&&d.d(),p&&p.d(),destroy_component(u)}}}function create_if_block_2$7(a){let e,n,t="Box",r,o,s,l;function c(h){a[18](h)}let f={handleClick:a[17],title:a[6]?"Hide":"Show",class:"mx-1"};return a[6]!==void 0&&(f.checked=a[6]),o=new Checkbox({props:f}),binding_callbacks.push(()=>bind(o,"checked",c)),{c(){e=element("div"),n=element("p"),n.textContent=t,r=space(),create_component(o.$$.fragment),this.h()},l(h){e=claim_element(h,"DIV",{class:!0});var u=children(e);n=claim_element(u,"P",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(n)!=="svelte-lhqu05"&&(n.textContent=t),r=claim_space(u),claim_component(o.$$.fragment,u),u.forEach(detach),this.h()},h(){attr(n,"class","font-light first-letter:uppercase"),attr(e,"class","flex gap-2 mt-2 items-center")},m(h,u){insert_hydration(h,e,u),append_hydration(e,n),append_hydration(e,r),mount_component(o,e,null),l=!0},p(h,u){const i={};u&64&&(i.handleClick=h[17]),u&64&&(i.title=h[6]?"Hide":"Show"),!s&&u&64&&(s=!0,i.checked=h[6],add_flush_callback(()=>s=!1)),o.$set(i)},i(h){l||(transition_in(o.$$.fragment,h),l=!0)},o(h){transition_out(o.$$.fragment,h),l=!1},d(h){h&&detach(e),destroy_component(o)}}}function create_if_block_1$b(a){let e,n,t="Mask",r,o,s,l;function c(h){a[20](h)}let f={handleClick:a[19],title:a[5]?"Hide":"Show",class:"mx-1"};return a[5]!==void 0&&(f.checked=a[5]),o=new Checkbox({props:f}),binding_callbacks.push(()=>bind(o,"checked",c)),{c(){e=element("div"),n=element("p"),n.textContent=t,r=space(),create_component(o.$$.fragment),this.h()},l(h){e=claim_element(h,"DIV",{class:!0});var u=children(e);n=claim_element(u,"P",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(n)!=="svelte-21ke58"&&(n.textContent=t),r=claim_space(u),claim_component(o.$$.fragment,u),u.forEach(detach),this.h()},h(){attr(n,"class","font-light first-letter:uppercase"),attr(e,"class","flex gap-2 mt-2 items-center")},m(h,u){insert_hydration(h,e,u),append_hydration(e,n),append_hydration(e,r),mount_component(o,e,null),l=!0},p(h,u){const i={};u&32&&(i.handleClick=h[19]),u&32&&(i.title=h[5]?"Hide":"Show"),!s&&u&32&&(s=!0,i.checked=h[5],add_flush_callback(()=>s=!1)),o.$set(i)},i(h){l||(transition_in(o.$$.fragment,h),l=!0)},o(h){transition_out(o.$$.fragment,h),l=!1},d(h){h&&detach(e),destroy_component(o)}}}function create_fragment$v(a){let e,n,t,r,o,s,l,c,f=a[0].id+"",h,u,i,d,p,_,m,g,b,v;r=new TooltipIconButton({props:{tooltipContent:a[7]?"Hide object":"Show object",$$slots:{default:[create_default_slot_3$5]},$$scope:{ctx:a}}}),r.$on("click",a[15]);let T=(a[3]||a[4])&&create_if_block_3$4(a);p=new TooltipIconButton({props:{tooltipContent:a[2]?"Hide features":"Show features",$$slots:{default:[create_default_slot$f]},$$scope:{ctx:a}}}),p.$on("click",a[16]);let y=a[2]&&create_if_block$l(a);return{c(){e=element("article"),n=element("div"),t=element("div"),create_component(r.$$.fragment),o=space(),s=element("button"),l=space(),c=element("span"),h=text(f),u=space(),i=element("div"),T&&T.c(),d=space(),create_component(p.$$.fragment),_=space(),y&&y.c(),this.h()},l(w){e=claim_element(w,"ARTICLE",{id:!0});var S=children(e);n=claim_element(S,"DIV",{class:!0,style:!0});var O=children(n);t=claim_element(O,"DIV",{class:!0});var P=children(t);claim_component(r.$$.fragment,P),o=claim_space(P),s=claim_element(P,"BUTTON",{class:!0,style:!0,title:!0}),children(s).forEach(detach),l=claim_space(P),c=claim_element(P,"SPAN",{class:!0});var E=children(c);h=claim_text(E,f),E.forEach(detach),P.forEach(detach),u=claim_space(O),i=claim_element(O,"DIV",{class:!0});var A=children(i);T&&T.l(A),d=claim_space(A),claim_component(p.$$.fragment,A),A.forEach(detach),O.forEach(detach),_=claim_space(S),y&&y.l(S),S.forEach(detach),this.h()},h(){attr(s,"class","rounded-full border w-3 h-3 mr-2 flex-[0_0_0.75rem]"),set_style(s,"background",a[1]),attr(s,"title","Highlight object"),attr(c,"class","truncate w-max flex-auto"),attr(t,"class","flex items-center flex-auto max-w-[50%]"),attr(i,"class","flex items-center"),attr(n,"class",cn("flex items-center mt-1  rounded justify-between text-slate-800 bg-white border-2 ")),set_style(n,"border-color",a[0].highlighted==="self"?a[1]:"transparent"),attr(e,"id",m=createObjectCardId(a[0]))},m(w,S){insert_hydration(w,e,S),append_hydration(e,n),append_hydration(n,t),mount_component(r,t,null),append_hydration(t,o),append_hydration(t,s),append_hydration(t,l),append_hydration(t,c),append_hydration(c,h),append_hydration(n,u),append_hydration(n,i),T&&T.m(i,null),append_hydration(i,d),mount_component(p,i,null),append_hydration(e,_),y&&y.m(e,null),g=!0,b||(v=[listen(s,"click",a[12]),listen(e,"mouseenter",a[21]),listen(e,"mouseleave",a[22])],b=!0)},p(w,[S]){const O={};S&128&&(O.tooltipContent=w[7]?"Hide object":"Show object"),S&8388736&&(O.$$scope={dirty:S,ctx:w}),r.$set(O),(!g||S&2)&&set_style(s,"background",w[1]),(!g||S&1)&&f!==(f=w[0].id+"")&&set_data(h,f),w[3]||w[4]?T?(T.p(w,S),S&24&&transition_in(T,1)):(T=create_if_block_3$4(w),T.c(),transition_in(T,1),T.m(i,d)):T&&(group_outros(),transition_out(T,1,1,()=>{T=null}),check_outros());const P={};S&4&&(P.tooltipContent=w[2]?"Hide features":"Show features"),S&8388612&&(P.$$scope={dirty:S,ctx:w}),p.$set(P),(!g||S&3)&&set_style(n,"border-color",w[0].highlighted==="self"?w[1]:"transparent"),w[2]?y?(y.p(w,S),S&4&&transition_in(y,1)):(y=create_if_block$l(w),y.c(),transition_in(y,1),y.m(e,null)):y&&(group_outros(),transition_out(y,1,1,()=>{y=null}),check_outros()),(!g||S&1&&m!==(m=createObjectCardId(w[0])))&&attr(e,"id",m)},i(w){g||(transition_in(r.$$.fragment,w),transition_in(T),transition_in(p.$$.fragment,w),transition_in(y),g=!0)},o(w){transition_out(r.$$.fragment,w),transition_out(T),transition_out(p.$$.fragment,w),transition_out(y),g=!1},d(w){w&&detach(e),destroy_component(r),T&&T.d(),destroy_component(p),y&&y.d(),b=!1,run_all(v)}}}function instance$A(a,e,n){let t,r,o,s,l,{itemObject:c}=e,{colorScale:f}=e,h,u=!1,i=!1;const d=(E,A,$=["bbox","mask"])=>{itemObjects.update(k=>k.map(D=>(E==="editing"&&(D.highlighted=D.id===c.id?"self":"none",D.highlighted=A?D.highlighted:"all",D.displayControl={...D.displayControl,editing:!1}),D.id===c.id&&(D=toggleObjectDisplayControl(D,E,$,A),itemBoxBeingEdited.update(()=>{var C;const I=D.datasetItemType==="video"&&((C=D.track[0])==null?void 0:C.keyBoxes[0]);return A&&I?{...I,objectId:D.id}:null})),D)))},p=()=>{itemObjects.update(E=>E.filter(A=>A.id!==c.id)),canSave.set(!0)},_=(E,A)=>{itemObjects.update($=>$.map(k=>(k.id===c.id&&(k.features={...k.features,[A]:{...k.features[A],value:E}}),k))),canSave.set(!0)},m=()=>{const E=c.highlighted==="self";itemObjects.update(A=>A.map($=>(E?$.highlighted="all":$.id===c.id?$.highlighted="self":$.highlighted="none",$)))},g=()=>{d("editing",!r),n(2,u=!0),!r&&selectedTool.set(panTool)},b=()=>d("hidden",o),v=()=>n(2,u=!u),T=()=>d("hidden",s,["bbox"]);function y(E){s=E,n(6,s),n(0,c)}const w=()=>d("hidden",l,["mask"]);function S(E){l=E,n(5,l),n(0,c)}const O=()=>n(3,i=!0),P=()=>n(3,i=u);return a.$$set=E=>{"itemObject"in E&&n(0,c=E.itemObject),"colorScale"in E&&n(14,f=E.colorScale)},a.$$.update=()=>{var E,A,$,k,D,I;a.$$.dirty&1&&n(8,t=createFeature(c.features)),a.$$.dirty&1&&n(4,r=((E=c.displayControl)==null?void 0:E.editing)||!1),a.$$.dirty&1&&n(7,o=!((A=c.displayControl)!=null&&A.hidden)),a.$$.dirty&1&&n(6,s=!((k=($=c.bbox)==null?void 0:$.displayControl)!=null&&k.hidden)),a.$$.dirty&1&&n(5,l=!((I=(D=c.mask)==null?void 0:D.displayControl)!=null&&I.hidden)),a.$$.dirty&16385&&n(1,h=f(c.id))},[c,h,u,i,r,l,s,o,t,d,p,_,m,g,f,b,v,T,y,w,S,O,P]}class ObjectCard extends SvelteComponent{constructor(e){super(),init(this,e,instance$A,create_fragment$v,safe_not_equal,{itemObject:0,colorScale:14})}}const get_modelSelection_slot_changes=a=>({}),get_modelSelection_slot_context=a=>({});function create_else_block$5(a){let e,n;return e=new Eye({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_if_block$k(a){let e,n;return e=new Eye_off({props:{class:"h-4"}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_default_slot$e(a){let e,n,t,r;const o=[create_if_block$k,create_else_block$5],s=[];function l(c,f){return c[2]==="hidden"?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,f){let h=e;e=l(c),e!==h&&(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n||(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function create_fragment$u(a){let e,n,t,r,o,s,l,c,f,h,u,i,d,p;r=new TooltipIconButton({props:{tooltipContent:a[3],$$slots:{default:[create_default_slot$e]},$$scope:{ctx:a}}}),r.$on("click",a[4]);const _=a[6].modelSelection,m=create_slot(_,a,a[7],get_modelSelection_slot_context),g=a[6].default,b=create_slot(g,a,a[7],null);return{c(){e=element("section"),n=element("div"),t=element("div"),create_component(r.$$.fragment),o=space(),s=element("h3"),l=text(a[0]),c=space(),m&&m.c(),f=space(),h=element("p"),u=text(a[1]),i=space(),d=element("div"),b&&b.c(),this.h()},l(v){e=claim_element(v,"SECTION",{class:!0});var T=children(e);n=claim_element(T,"DIV",{class:!0});var y=children(n);t=claim_element(y,"DIV",{class:!0});var w=children(t);claim_component(r.$$.fragment,w),o=claim_space(w),s=claim_element(w,"H3",{class:!0});var S=children(s);l=claim_text(S,a[0]),S.forEach(detach),c=claim_space(w),m&&m.l(w),f=claim_space(w),h=claim_element(w,"P",{});var O=children(h);u=claim_text(O,a[1]),O.forEach(detach),w.forEach(detach),y.forEach(detach),i=claim_space(T),d=claim_element(T,"DIV",{class:!0});var P=children(d);b&&b.l(P),P.forEach(detach),T.forEach(detach),this.h()},h(){attr(s,"class","uppercase font-medium grow"),attr(t,"class","flex items-center gap-3 w-full"),attr(n,"class","flex items-center justify-between text-slate-800"),attr(d,"class","p-2 pt-0 max-h-full overflow-y-auto"),attr(e,"class","h-full pb-10")},m(v,T){insert_hydration(v,e,T),append_hydration(e,n),append_hydration(n,t),mount_component(r,t,null),append_hydration(t,o),append_hydration(t,s),append_hydration(s,l),append_hydration(t,c),m&&m.m(t,null),append_hydration(t,f),append_hydration(t,h),append_hydration(h,u),append_hydration(e,i),append_hydration(e,d),b&&b.m(d,null),p=!0},p(v,[T]){const y={};T&8&&(y.tooltipContent=v[3]),T&132&&(y.$$scope={dirty:T,ctx:v}),r.$set(y),(!p||T&1)&&set_data(l,v[0]),m&&m.p&&(!p||T&128)&&update_slot_base(m,_,v,v[7],p?get_slot_changes(_,v[7],T,get_modelSelection_slot_changes):get_all_dirty_from_scope(v[7]),get_modelSelection_slot_context),(!p||T&2)&&set_data(u,v[1]),b&&b.p&&(!p||T&128)&&update_slot_base(b,g,v,v[7],p?get_slot_changes(g,v[7],T,null):get_all_dirty_from_scope(v[7]),null)},i(v){p||(transition_in(r.$$.fragment,v),transition_in(m,v),transition_in(b,v),p=!0)},o(v){transition_out(r.$$.fragment,v),transition_out(m,v),transition_out(b,v),p=!1},d(v){v&&detach(e),destroy_component(r),m&&m.d(v),b&&b.d(v)}}}function instance$z(a,e,n){let t,{$$slots:r={},$$scope:o}=e,{sectionTitle:s}=e,{modelName:l}=e,{numberOfItem:c}=e,f="shown";itemObjects.subscribe(u=>{if(!u.length)return;const i=u.filter(_=>_.source_id===l);i.every(_=>{var m;return(m=_.displayControl)==null?void 0:m.hidden})&&n(2,f="hidden"),i.every(_=>{var m;return!((m=_.displayControl)!=null&&m.hidden)})&&n(2,f="shown")});const h=()=>{f==="hidden"?n(2,f="shown"):n(2,f="hidden")};return a.$$set=u=>{"sectionTitle"in u&&n(0,s=u.sectionTitle),"modelName"in u&&n(5,l=u.modelName),"numberOfItem"in u&&n(1,c=u.numberOfItem),"$$scope"in u&&n(7,o=u.$$scope)},a.$$.update=()=>{a.$$.dirty&36&&n(3,t=f==="hidden"?`Show ${l} objects`:`Hide ${l} objects`),a.$$.dirty&36&&itemObjects.update(u=>u.map(i=>{const d=f==="hidden";return l===GROUND_TRUTH?i.source_id===l?toggleObjectDisplayControl(i,"hidden",["bbox","mask"],d):i:EXISTING_SOURCE_IDS.includes(i.source_id)?i:i.source_id===l?toggleObjectDisplayControl(i,"hidden",["bbox","mask"],d):toggleObjectDisplayControl(i,"hidden",["bbox","mask"],!0)}))},[s,c,f,t,h,l,r,o]}class ObjectsModelSection extends SvelteComponent{constructor(e){super(),init(this,e,instance$z,create_fragment$u,safe_not_equal,{sectionTitle:0,modelName:5,numberOfItem:1})}}function get_each_context$7(a,e,n){const t=a.slice();return t[13]=e[n],t[15]=n,t}function create_if_block_4$1(a){var u;let e,n,t,r,o=a[13].label+"",s,l,c;function f(...i){return a[9](a[13],...i)}n=new Checkbox({props:{handleClick:f,checked:((u=a[1][a[13].name])==null?void 0:u.value)===1}});let h=a[13].required&&create_if_block_5();return{c(){e=element("div"),create_component(n.$$.fragment),t=space(),r=element("span"),s=text(o),l=space(),h&&h.c(),this.h()},l(i){e=claim_element(i,"DIV",{class:!0});var d=children(e);claim_component(n.$$.fragment,d),t=claim_space(d),r=claim_element(d,"SPAN",{});var p=children(r);s=claim_text(p,o),l=claim_space(p),h&&h.l(p),p.forEach(detach),d.forEach(detach),this.h()},h(){attr(e,"class","flex gap-4 items-center")},m(i,d){insert_hydration(i,e,d),mount_component(n,e,null),append_hydration(e,t),append_hydration(e,r),append_hydration(r,s),append_hydration(r,l),h&&h.m(r,null),c=!0},p(i,d){var _;a=i;const p={};d&1&&(p.handleClick=f),d&3&&(p.checked=((_=a[1][a[13].name])==null?void 0:_.value)===1),n.$set(p),(!c||d&1)&&o!==(o=a[13].label+"")&&set_data(s,o),a[13].required?h||(h=create_if_block_5(),h.c(),h.m(r,null)):h&&(h.d(1),h=null)},i(i){c||(transition_in(n.$$.fragment,i),c=!0)},o(i){transition_out(n.$$.fragment,i),c=!1},d(i){i&&detach(e),destroy_component(n),h&&h.d()}}}function create_if_block_5(a){let e,n="*";return{c(){e=element("span"),e.textContent=n},l(t){e=claim_element(t,"SPAN",{"data-svelte-h":!0}),get_svelte_dataset(e)!=="svelte-140b0co"&&(e.textContent=n)},m(t,r){insert_hydration(t,e,r)},d(t){t&&detach(e)}}}function create_if_block_3$3(a){let e,n;function t(...r){return a[10](a[13],...r)}return e=new Combobox({props:{placeholder:`Select a ${a[13].label}`,listItems:a[13].options,saveValue:t}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,o){mount_component(e,r,o),n=!0},p(r,o){a=r;const s={};o&1&&(s.placeholder=`Select a ${a[13].label}`),o&1&&(s.listItems=a[13].options),o&1&&(s.saveValue=t),e.$set(s)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_if_block$j(a){let e,n,t=a[13].label+"",r,o,s,l,c,f,h,u=a[13].required&&create_if_block_2$6();const i=[create_if_block_1$a,create_else_block$4],d=[];function p(_,m){return _[13].type==="str"?0:1}return l=p(a),c=d[l]=i[l](a),{c(){e=element("div"),n=element("span"),r=text(t),o=space(),u&&u.c(),s=space(),c.c(),f=space()},l(_){e=claim_element(_,"DIV",{});var m=children(e);n=claim_element(m,"SPAN",{});var g=children(n);r=claim_text(g,t),o=claim_space(g),u&&u.l(g),g.forEach(detach),s=claim_space(m),c.l(m),f=claim_space(m),m.forEach(detach)},m(_,m){insert_hydration(_,e,m),append_hydration(e,n),append_hydration(n,r),append_hydration(n,o),u&&u.m(n,null),append_hydration(e,s),d[l].m(e,null),append_hydration(e,f),h=!0},p(_,m){(!h||m&1)&&t!==(t=_[13].label+"")&&set_data(r,t),_[13].required?u||(u=create_if_block_2$6(),u.c(),u.m(n,null)):u&&(u.d(1),u=null);let g=l;l=p(_),l===g?d[l].p(_,m):(group_outros(),transition_out(d[g],1,1,()=>{d[g]=null}),check_outros(),c=d[l],c?c.p(_,m):(c=d[l]=i[l](_),c.c()),transition_in(c,1),c.m(e,f))},i(_){h||(transition_in(c),h=!0)},o(_){transition_out(c),h=!1},d(_){_&&detach(e),u&&u.d(),d[l].d()}}}function create_if_block_2$6(a){let e,n="*";return{c(){e=element("span"),e.textContent=n},l(t){e=claim_element(t,"SPAN",{"data-svelte-h":!0}),get_svelte_dataset(e)!=="svelte-140b0co"&&(e.textContent=n)},m(t,r){insert_hydration(t,e,r)},d(t){t&&detach(e)}}}function create_else_block$4(a){var r;let e,n;function t(...o){return a[12](a[13],...o)}return e=new Input({props:{type:"number",step:a[13].type==="int"?"1":"any",value:((r=a[1][a[13].name])==null?void 0:r.value)||"",autofocus:a[15]===0}}),e.$on("keyup",keyup_handler),e.$on("input",t),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,s){var c;a=o;const l={};s&1&&(l.step=a[13].type==="int"?"1":"any"),s&3&&(l.value=((c=a[1][a[13].name])==null?void 0:c.value)||""),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function create_if_block_1$a(a){var r,o,s;let e,n;function t(...l){return a[11](a[13],...l)}return e=new AutoCompleteFeatureInput({props:{value:a[5](a[13].name),onTextInputChange:t,featureList:mapFeatureList((r=a[3].featuresList)==null?void 0:r.objects[a[13].name]),autofocus:a[15]===0&&a[2],isInputEnabled:!((s=(o=a[3].featuresList)==null?void 0:o.objects[a[13].name])!=null&&s.restricted)}}),{c(){create_component(e.$$.fragment)},l(l){claim_component(e.$$.fragment,l)},m(l,c){mount_component(e,l,c),n=!0},p(l,c){var h,u,i;a=l;const f={};c&1&&(f.value=a[5](a[13].name)),c&1&&(f.onTextInputChange=t),c&9&&(f.featureList=mapFeatureList((h=a[3].featuresList)==null?void 0:h.objects[a[13].name])),c&4&&(f.autofocus=a[15]===0&&a[2]),c&9&&(f.isInputEnabled=!((i=(u=a[3].featuresList)==null?void 0:u.objects[a[13].name])!=null&&i.restricted)),e.$set(f)},i(l){n||(transition_in(e.$$.fragment,l),n=!0)},o(l){transition_out(e.$$.fragment,l),n=!1},d(l){destroy_component(e,l)}}}function create_each_block$7(a){let e,n,t=["int","float","str"].includes(a[13].type),r,o,s=a[13].type==="bool"&&create_if_block_4$1(a),l=a[13].type==="list"&&create_if_block_3$3(a),c=t&&create_if_block$j(a);return{c(){s&&s.c(),e=space(),l&&l.c(),n=space(),c&&c.c(),r=empty()},l(f){s&&s.l(f),e=claim_space(f),l&&l.l(f),n=claim_space(f),c&&c.l(f),r=empty()},m(f,h){s&&s.m(f,h),insert_hydration(f,e,h),l&&l.m(f,h),insert_hydration(f,n,h),c&&c.m(f,h),insert_hydration(f,r,h),o=!0},p(f,h){f[13].type==="bool"?s?(s.p(f,h),h&1&&transition_in(s,1)):(s=create_if_block_4$1(f),s.c(),transition_in(s,1),s.m(e.parentNode,e)):s&&(group_outros(),transition_out(s,1,1,()=>{s=null}),check_outros()),f[13].type==="list"?l?(l.p(f,h),h&1&&transition_in(l,1)):(l=create_if_block_3$3(f),l.c(),transition_in(l,1),l.m(n.parentNode,n)):l&&(group_outros(),transition_out(l,1,1,()=>{l=null}),check_outros()),h&1&&(t=["int","float","str"].includes(f[13].type)),t?c?(c.p(f,h),h&1&&transition_in(c,1)):(c=create_if_block$j(f),c.c(),transition_in(c,1),c.m(r.parentNode,r)):c&&(group_outros(),transition_out(c,1,1,()=>{c=null}),check_outros())},i(f){o||(transition_in(s),transition_in(l),transition_in(c),o=!0)},o(f){transition_out(s),transition_out(l),transition_out(c),o=!1},d(f){f&&(detach(e),detach(n),detach(r)),s&&s.d(f),l&&l.d(f),c&&c.d(f)}}}function create_fragment$t(a){let e,n,t=ensure_array_like(a[0]),r=[];for(let s=0;s<t.length;s+=1)r[s]=create_each_block$7(get_each_context$7(a,t,s));const o=s=>transition_out(r[s],1,1,()=>{r[s]=null});return{c(){for(let s=0;s<r.length;s+=1)r[s].c();e=empty()},l(s){for(let l=0;l<r.length;l+=1)r[l].l(s);e=empty()},m(s,l){for(let c=0;c<r.length;c+=1)r[c]&&r[c].m(s,l);insert_hydration(s,e,l),n=!0},p(s,[l]){if(l&63){t=ensure_array_like(s[0]);let c;for(c=0;c<t.length;c+=1){const f=get_each_context$7(s,t,c);r[c]?(r[c].p(f,l),transition_in(r[c],1)):(r[c]=create_each_block$7(f),r[c].c(),transition_in(r[c],1),r[c].m(e.parentNode,e))}for(group_outros(),c=t.length;c<r.length;c+=1)o(c);check_outros()}},i(s){if(!n){for(let l=0;l<t.length;l+=1)transition_in(r[l]);n=!0}},o(s){r=r.filter(Boolean);for(let l=0;l<r.length;l+=1)transition_out(r[l]);n=!1},d(s){s&&detach(e),destroy_each(r,s)}}}const keyup_handler=a=>a.stopPropagation();function instance$y(a,e,n){let t;component_subscribe(a,itemMetas,m=>n(3,t=m));let{isFormValid:r=!1}=e,{formInputs:o=[]}=e,{objectProperties:s={}}=e,{initialValues:l={}}=e,{isAutofocusEnabled:c=!0}=e,f;itemMetas.subscribe(m=>{const g=Object.values(m.objectFeatures||defaultObjectFeatures).map(b=>({...b,label:b.name,required:!0,type:b.dtype}));n(8,f=createSchemaFromFeatures(g)),n(0,o=createObjectInputsSchema.parse(g))});const h=(m,g)=>{n(6,s[g]=m,s)},u=m=>{var b;const g=(b=l[m])==null?void 0:b.value;return typeof g=="string"?g:""},i=(m,g)=>h(g,m.name),d=(m,g)=>h(g,m.name),p=(m,g)=>h(g,m.name),_=(m,g)=>h(Number(g.currentTarget.value),m.name);return a.$$set=m=>{"isFormValid"in m&&n(7,r=m.isFormValid),"formInputs"in m&&n(0,o=m.formInputs),"objectProperties"in m&&n(6,s=m.objectProperties),"initialValues"in m&&n(1,l=m.initialValues),"isAutofocusEnabled"in m&&n(2,c=m.isAutofocusEnabled)},a.$$.update=()=>{if(a.$$.dirty&2&&Object.values(l).forEach(m=>{typeof m.value!="object"&&n(6,s[m.name]=m.value,s)}),a.$$.dirty&320){const m=f.safeParse(s);n(7,r=m.success)}},[o,l,c,t,h,u,s,r,f,i,d,p,_]}class CreateFeatureInputs extends SvelteComponent{constructor(e){super(),init(this,e,instance$y,create_fragment$t,safe_not_equal,{isFormValid:7,formInputs:0,objectProperties:6,initialValues:1,isAutofocusEnabled:2})}}function create_if_block$i(a){let e,n,t,r,o,s="PRE ANNOTATION",l,c,f,h;t=new Root$3({props:{$$slots:{default:[create_default_slot_3$4]},$$scope:{ctx:a}}});let u=a[3]&&create_if_block_3$2(a),i=a[3]&&create_if_block_1$9(a);return{c(){e=element("div"),n=element("div"),create_component(t.$$.fragment),r=space(),o=element("h3"),o.textContent=s,l=space(),u&&u.c(),c=space(),i&&i.c(),f=empty(),this.h()},l(d){e=claim_element(d,"DIV",{class:!0});var p=children(e);n=claim_element(p,"DIV",{class:!0});var _=children(n);claim_component(t.$$.fragment,_),r=claim_space(_),o=claim_element(_,"H3",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(o)!=="svelte-k5yb9e"&&(o.textContent=s),_.forEach(detach),l=claim_space(p),u&&u.l(p),p.forEach(detach),c=claim_space(d),i&&i.l(d),f=empty(),this.h()},h(){attr(o,"class","uppercase font-medium"),attr(n,"class","flex gap-4"),attr(e,"class","flex justify-between my-4")},m(d,p){insert_hydration(d,e,p),append_hydration(e,n),mount_component(t,n,null),append_hydration(n,r),append_hydration(n,o),append_hydration(e,l),u&&u.m(e,null),insert_hydration(d,c,p),i&&i.m(d,p),insert_hydration(d,f,p),h=!0},p(d,p){const _={};p&32769&&(_.$$scope={dirty:p,ctx:d}),t.$set(_),d[3]?u?u.p(d,p):(u=create_if_block_3$2(d),u.c(),u.m(e,null)):u&&(u.d(1),u=null),d[3]?i?(i.p(d,p),p&8&&transition_in(i,1)):(i=create_if_block_1$9(d),i.c(),transition_in(i,1),i.m(f.parentNode,f)):i&&(group_outros(),transition_out(i,1,1,()=>{i=null}),check_outros())},i(d){h||(transition_in(t.$$.fragment,d),transition_in(i),h=!0)},o(d){transition_out(t.$$.fragment,d),transition_out(i),h=!1},d(d){d&&(detach(e),detach(c),detach(f)),destroy_component(t),u&&u.d(),i&&i.d(d)}}}function create_default_slot_5$2(a){let e,n;return e=new SwitchRoot({props:{class:cn({"pointer-events-none":!a[0].length}),onChange:a[9]}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r&1&&(o.class=cn({"pointer-events-none":!t[0].length})),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_if_block_4(a){let e,n;return e=new Tooltip_content({props:{$$slots:{default:[create_default_slot_4$3]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_default_slot_4$3(a){let e,n="No objects to annotate";return{c(){e=element("p"),e.textContent=n},l(t){e=claim_element(t,"P",{"data-svelte-h":!0}),get_svelte_dataset(e)!=="svelte-1mgoitw"&&(e.textContent=n)},m(t,r){insert_hydration(t,e,r)},p:noop,d(t){t&&detach(e)}}}function create_default_slot_3$4(a){let e,n,t,r;e=new Trigger$2({props:{$$slots:{default:[create_default_slot_5$2]},$$scope:{ctx:a}}});let o=a[0].length===0&&create_if_block_4(a);return{c(){create_component(e.$$.fragment),n=space(),o&&o.c(),t=empty()},l(s){claim_component(e.$$.fragment,s),n=claim_space(s),o&&o.l(s),t=empty()},m(s,l){mount_component(e,s,l),insert_hydration(s,n,l),o&&o.m(s,l),insert_hydration(s,t,l),r=!0},p(s,l){const c={};l&32769&&(c.$$scope={dirty:l,ctx:s}),e.$set(c),s[0].length===0?o?l&1&&transition_in(o,1):(o=create_if_block_4(s),o.c(),transition_in(o,1),o.m(t.parentNode,t)):o&&(group_outros(),transition_out(o,1,1,()=>{o=null}),check_outros())},i(s){r||(transition_in(e.$$.fragment,s),transition_in(o),r=!0)},o(s){transition_out(e.$$.fragment,s),transition_out(o),r=!1},d(s){s&&(detach(n),detach(t)),destroy_component(e,s),o&&o.d(s)}}}function create_if_block_3$2(a){let e,n=a[1].length+"",t;return{c(){e=element("span"),t=text(n)},l(r){e=claim_element(r,"SPAN",{});var o=children(e);t=claim_text(o,n),o.forEach(detach)},m(r,o){insert_hydration(r,e,o),append_hydration(e,t)},p(r,o){o&2&&n!==(n=r[1].length+"")&&set_data(t,n)},d(r){r&&detach(e)}}}function create_if_block_1$9(a){let e,n,t,r,o,s,l,c;n=new TooltipIconButton({props:{tooltipContent:"confidence slider",$$slots:{default:[create_default_slot_2$4]},$$scope:{ctx:a}}}),o=new SliderWithValue({props:{onChange:a[10],max:1,step:.01}});let f=a[2]&&create_if_block_2$5(a);return{c(){e=element("div"),create_component(n.$$.fragment),t=space(),r=element("div"),create_component(o.$$.fragment),s=space(),f&&f.c(),l=empty(),this.h()},l(h){e=claim_element(h,"DIV",{class:!0});var u=children(e);claim_component(n.$$.fragment,u),t=claim_space(u),r=claim_element(u,"DIV",{class:!0});var i=children(r);claim_component(o.$$.fragment,i),i.forEach(detach),u.forEach(detach),s=claim_space(h),f&&f.l(h),l=empty(),this.h()},h(){attr(r,"class","px-8 w-full"),attr(e,"class","my-2 flex items-center")},m(h,u){insert_hydration(h,e,u),mount_component(n,e,null),append_hydration(e,t),append_hydration(e,r),mount_component(o,r,null),insert_hydration(h,s,u),f&&f.m(h,u),insert_hydration(h,l,u),c=!0},p(h,u){const i={};u&32768&&(i.$$scope={dirty:u,ctx:h}),n.$set(i),h[2]?f?(f.p(h,u),u&4&&transition_in(f,1)):(f=create_if_block_2$5(h),f.c(),transition_in(f,1),f.m(l.parentNode,l)):f&&(group_outros(),transition_out(f,1,1,()=>{f=null}),check_outros())},i(h){c||(transition_in(n.$$.fragment,h),transition_in(o.$$.fragment,h),transition_in(f),c=!0)},o(h){transition_out(n.$$.fragment,h),transition_out(o.$$.fragment,h),transition_out(f),c=!1},d(h){h&&(detach(e),detach(s),detach(l)),destroy_component(n),destroy_component(o),f&&f.d(h)}}}function create_default_slot_2$4(a){let e,n;return e=new Filter({}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_if_block_2$5(a){let e,n,t,r,o,s=a[2].id+"",l,c,f,h=a[2].id,u,i,d,p,_,m;t=new BoxSelectIcon({props:{color:a[5]}});let g=create_key_block$2(a);return d=new PrimaryButton({props:{isSelected:!0,disabled:!a[4],$$slots:{default:[create_default_slot_1$7]},$$scope:{ctx:a}}}),d.$on("click",a[7]),_=new PrimaryButton({props:{$$slots:{default:[create_default_slot$d]},$$scope:{ctx:a}}}),_.$on("click",a[8]),{c(){e=element("div"),n=element("p"),create_component(t.$$.fragment),r=space(),o=element("span"),l=text(s),c=space(),f=element("div"),g.c(),u=space(),i=element("div"),create_component(d.$$.fragment),p=space(),create_component(_.$$.fragment),this.h()},l(b){e=claim_element(b,"DIV",{class:!0});var v=children(e);n=claim_element(v,"P",{class:!0});var T=children(n);claim_component(t.$$.fragment,T),r=claim_space(T),o=claim_element(T,"SPAN",{});var y=children(o);l=claim_text(y,s),y.forEach(detach),T.forEach(detach),c=claim_space(v),f=claim_element(v,"DIV",{class:!0});var w=children(f);g.l(w),w.forEach(detach),u=claim_space(v),i=claim_element(v,"DIV",{class:!0});var S=children(i);claim_component(d.$$.fragment,S),p=claim_space(S),claim_component(_.$$.fragment,S),S.forEach(detach),v.forEach(detach),this.h()},h(){attr(n,"class","flex gap-2"),attr(f,"class","flex flex-col gap-4 py-4"),attr(i,"class","flex gap-4 mt-4 justify-center sticky bottom-0 pb-2 left-[50%] bg-white"),attr(e,"class","bg-white rounded-sm p-4 pb-0 mt-4 relative max-h-[60vh] overflow-y-auto")},m(b,v){insert_hydration(b,e,v),append_hydration(e,n),mount_component(t,n,null),append_hydration(n,r),append_hydration(n,o),append_hydration(o,l),append_hydration(e,c),append_hydration(e,f),g.m(f,null),append_hydration(e,u),append_hydration(e,i),mount_component(d,i,null),append_hydration(i,p),mount_component(_,i,null),m=!0},p(b,v){const T={};v&32&&(T.color=b[5]),t.$set(T),(!m||v&4)&&s!==(s=b[2].id+"")&&set_data(l,s),v&4&&safe_not_equal(h,h=b[2].id)?(group_outros(),transition_out(g,1,1,noop),check_outros(),g=create_key_block$2(b),g.c(),transition_in(g,1),g.m(f,null)):g.p(b,v);const y={};v&16&&(y.disabled=!b[4]),v&32768&&(y.$$scope={dirty:v,ctx:b}),d.$set(y);const w={};v&32768&&(w.$$scope={dirty:v,ctx:b}),_.$set(w)},i(b){m||(transition_in(t.$$.fragment,b),transition_in(g),transition_in(d.$$.fragment,b),transition_in(_.$$.fragment,b),m=!0)},o(b){transition_out(t.$$.fragment,b),transition_out(g),transition_out(d.$$.fragment,b),transition_out(_.$$.fragment,b),m=!1},d(b){b&&detach(e),destroy_component(t),g.d(b),destroy_component(d),destroy_component(_)}}}function create_key_block$2(a){let e,n,t,r;function o(c){a[12](c)}function s(c){a[13](c)}let l={initialValues:a[2].features,isAutofocusEnabled:!1};return a[4]!==void 0&&(l.isFormValid=a[4]),a[6]!==void 0&&(l.objectProperties=a[6]),e=new CreateFeatureInputs({props:l}),binding_callbacks.push(()=>bind(e,"isFormValid",o)),binding_callbacks.push(()=>bind(e,"objectProperties",s)),{c(){create_component(e.$$.fragment)},l(c){claim_component(e.$$.fragment,c)},m(c,f){mount_component(e,c,f),r=!0},p(c,f){const h={};f&4&&(h.initialValues=c[2].features),!n&&f&16&&(n=!0,h.isFormValid=c[4],add_flush_callback(()=>n=!1)),!t&&f&64&&(t=!0,h.objectProperties=c[6],add_flush_callback(()=>t=!1)),e.$set(h)},i(c){r||(transition_in(e.$$.fragment,c),r=!0)},o(c){transition_out(e.$$.fragment,c),r=!1},d(c){destroy_component(e,c)}}}function create_default_slot_1$7(a){let e,n,t;return e=new Check({}),{c(){create_component(e.$$.fragment),n=text("Accept")},l(r){claim_component(e.$$.fragment,r),n=claim_text(r,"Accept")},m(r,o){mount_component(e,r,o),insert_hydration(r,n,o),t=!0},i(r){t||(transition_in(e.$$.fragment,r),t=!0)},o(r){transition_out(e.$$.fragment,r),t=!1},d(r){r&&detach(n),destroy_component(e,r)}}}function create_default_slot$d(a){let e;return{c(){e=text("Reject")},l(n){e=claim_text(n,"Reject")},m(n,t){insert_hydration(n,e,t)},d(n){n&&detach(e)}}}function create_fragment$s(a){let e,n,t=a[0].length>0&&create_if_block$i(a);return{c(){t&&t.c(),e=empty()},l(r){t&&t.l(r),e=empty()},m(r,o){t&&t.m(r,o),insert_hydration(r,e,o),n=!0},p(r,[o]){r[0].length>0?t?(t.p(r,o),o&1&&transition_in(t,1)):(t=create_if_block$i(r),t.c(),transition_in(t,1),t.m(e.parentNode,e)):t&&(group_outros(),transition_out(t,1,1,()=>{t=null}),check_outros())},i(r){n||(transition_in(t),n=!0)},o(r){transition_out(t),n=!1},d(r){r&&detach(e),t&&t.d(r)}}}function instance$x(a,e,n){let t,r;component_subscribe(a,preAnnotationIsActive,b=>n(3,r=b));let{colorScale:o}=e,s=[],l=[],c=!1,f=[0],h,u={};itemObjects.subscribe(b=>{n(0,s=getObjectsToPreAnnotate(b)),n(1,l=sortAndFilterObjectsToAnnotate(s,f))});const i=()=>{itemObjects.update(b=>[...mapObjectWithNewStatus(b,l,"accepted",u),{...t,review_state:"accepted",source_id:GROUND_TRUTH,id:nanoid(10),highlighted:"none"}]),canSave.set(!0)},d=()=>{itemObjects.update(b=>mapObjectWithNewStatus(b,l,"rejected")),canSave.set(!0)},p=b=>{set_store_value(preAnnotationIsActive,r=b||!1,r),itemObjects.update(v=>{const T=getObjectsToPreAnnotate(v),y=sortAndFilterObjectsToAnnotate(T,f);return v.map(w=>{var S;return w.highlighted=r?"none":"all",w.id===((S=y[0])==null?void 0:S.id)&&r&&(w.highlighted="self"),w})})},_=b=>{f=b||[0],n(1,l=sortAndFilterObjectsToAnnotate(s,f)),s.length===0&&preAnnotationIsActive.set(!1)};function m(b){c=b,n(4,c)}function g(b){u=b,n(6,u)}return a.$$set=b=>{"colorScale"in b&&n(11,o=b.colorScale)},a.$$.update=()=>{a.$$.dirty&2&&n(2,t=l[0]),a.$$.dirty&2052&&n(5,h=o((t==null?void 0:t.id)||"")),a.$$.dirty&9&&r&&s.length===0&&(preAnnotationIsActive.set(!1),itemObjects.update(b=>b.map(v=>(v.highlighted="all",v))))},[s,l,t,r,c,h,u,i,d,p,_,o,m,g]}class PreAnnotation extends SvelteComponent{constructor(e){super(),init(this,e,instance$x,create_fragment$s,safe_not_equal,{colorScale:11})}}function get_each_context$6(a,e,n){const t=a.slice();return t[9]=e[n],t[10]=e,t[11]=n,t}function get_each_context_1$2(a,e,n){const t=a.slice();return t[9]=e[n],t[12]=e,t[13]=n,t}function create_if_block$h(a){let e,n,t,r,o;n=new ObjectsModelSection({props:{sectionTitle:"Ground truth",modelName:GROUND_TRUTH,numberOfItem:a[0][GROUND_TRUTH].length,$$slots:{default:[create_default_slot_1$6]},$$scope:{ctx:a}}});let s=a[1]&&create_if_block_1$8(a);return{c(){e=element("div"),create_component(n.$$.fragment),t=space(),s&&s.c(),this.h()},l(l){e=claim_element(l,"DIV",{class:!0});var c=children(e);claim_component(n.$$.fragment,c),t=claim_space(c),s&&s.l(c),c.forEach(detach),this.h()},h(){attr(e,"class",r=cn("gap-4 grow grid grid-cols-1 grid-rows-2 h-full",{block:!a[1]}))},m(l,c){insert_hydration(l,e,c),mount_component(n,e,null),append_hydration(e,t),s&&s.m(e,null),o=!0},p(l,c){const f={};c&1&&(f.numberOfItem=l[0][GROUND_TRUTH].length),c&16385&&(f.$$scope={dirty:c,ctx:l}),n.$set(f),l[1]?s?(s.p(l,c),c&2&&transition_in(s,1)):(s=create_if_block_1$8(l),s.c(),transition_in(s,1),s.m(e,null)):s&&(group_outros(),transition_out(s,1,1,()=>{s=null}),check_outros()),(!o||c&2&&r!==(r=cn("gap-4 grow grid grid-cols-1 grid-rows-2 h-full",{block:!l[1]})))&&attr(e,"class",r)},i(l){o||(transition_in(n.$$.fragment,l),transition_in(s),o=!0)},o(l){transition_out(n.$$.fragment,l),transition_out(s),o=!1},d(l){l&&detach(e),destroy_component(n),s&&s.d()}}}function create_each_block_1$2(a){let e,n,t;function r(s){a[5](s,a[9],a[12],a[13])}let o={colorScale:a[3]};return a[9]!==void 0&&(o.itemObject=a[9]),e=new ObjectCard({props:o}),binding_callbacks.push(()=>bind(e,"itemObject",r)),{c(){create_component(e.$$.fragment)},l(s){claim_component(e.$$.fragment,s)},m(s,l){mount_component(e,s,l),t=!0},p(s,l){a=s;const c={};!n&&l&1&&(n=!0,c.itemObject=a[9],add_flush_callback(()=>n=!1)),e.$set(c)},i(s){t||(transition_in(e.$$.fragment,s),t=!0)},o(s){transition_out(e.$$.fragment,s),t=!1},d(s){destroy_component(e,s)}}}function create_default_slot_1$6(a){let e,n,t=ensure_array_like(a[0][GROUND_TRUTH]),r=[];for(let s=0;s<t.length;s+=1)r[s]=create_each_block_1$2(get_each_context_1$2(a,t,s));const o=s=>transition_out(r[s],1,1,()=>{r[s]=null});return{c(){for(let s=0;s<r.length;s+=1)r[s].c();e=empty()},l(s){for(let l=0;l<r.length;l+=1)r[l].l(s);e=empty()},m(s,l){for(let c=0;c<r.length;c+=1)r[c]&&r[c].m(s,l);insert_hydration(s,e,l),n=!0},p(s,l){if(l&9){t=ensure_array_like(s[0][GROUND_TRUTH]);let c;for(c=0;c<t.length;c+=1){const f=get_each_context_1$2(s,t,c);r[c]?(r[c].p(f,l),transition_in(r[c],1)):(r[c]=create_each_block_1$2(f),r[c].c(),transition_in(r[c],1),r[c].m(e.parentNode,e))}for(group_outros(),c=t.length;c<r.length;c+=1)o(c);check_outros()}},i(s){if(!n){for(let l=0;l<t.length;l+=1)transition_in(r[l]);n=!0}},o(s){r=r.filter(Boolean);for(let l=0;l<r.length;l+=1)transition_out(r[l]);n=!1},d(s){s&&detach(e),destroy_each(r,s)}}}function create_if_block_1$8(a){var t;let e,n;return e=new ObjectsModelSection({props:{sectionTitle:"Model run",modelName:a[1],numberOfItem:((t=a[0][a[1]])==null?void 0:t.length)||0,$$slots:{modelSelection:[create_modelSelection_slot],default:[create_default_slot$c]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,o){mount_component(e,r,o),n=!0},p(r,o){var l;const s={};o&2&&(s.modelName=r[1]),o&3&&(s.numberOfItem=((l=r[0][r[1]])==null?void 0:l.length)||0),o&16387&&(s.$$scope={dirty:o,ctx:r}),e.$set(s)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_each_block$6(a){let e,n,t;function r(s){a[7](s,a[9],a[10],a[11])}let o={colorScale:a[3]};return a[9]!==void 0&&(o.itemObject=a[9]),e=new ObjectCard({props:o}),binding_callbacks.push(()=>bind(e,"itemObject",r)),{c(){create_component(e.$$.fragment)},l(s){claim_component(e.$$.fragment,s)},m(s,l){mount_component(e,s,l),t=!0},p(s,l){a=s;const c={};!n&&l&3&&(n=!0,c.itemObject=a[9],add_flush_callback(()=>n=!1)),e.$set(c)},i(s){t||(transition_in(e.$$.fragment,s),t=!0)},o(s){transition_out(e.$$.fragment,s),t=!1},d(s){destroy_component(e,s)}}}function create_default_slot$c(a){let e,n,t=ensure_array_like(a[0][a[1]]||[]),r=[];for(let s=0;s<t.length;s+=1)r[s]=create_each_block$6(get_each_context$6(a,t,s));const o=s=>transition_out(r[s],1,1,()=>{r[s]=null});return{c(){for(let s=0;s<r.length;s+=1)r[s].c();e=empty()},l(s){for(let l=0;l<r.length;l+=1)r[l].l(s);e=empty()},m(s,l){for(let c=0;c<r.length;c+=1)r[c]&&r[c].m(s,l);insert_hydration(s,e,l),n=!0},p(s,l){if(l&11){t=ensure_array_like(s[0][s[1]]||[]);let c;for(c=0;c<t.length;c+=1){const f=get_each_context$6(s,t,c);r[c]?(r[c].p(f,l),transition_in(r[c],1)):(r[c]=create_each_block$6(f),r[c].c(),transition_in(r[c],1),r[c].m(e.parentNode,e))}for(group_outros(),c=t.length;c<r.length;c+=1)o(c);check_outros()}},i(s){if(!n){for(let l=0;l<t.length;l+=1)transition_in(r[l]);n=!0}},o(s){r=r.filter(Boolean);for(let l=0;l<r.length;l+=1)transition_out(r[l]);n=!1},d(s){s&&detach(e),destroy_each(r,s)}}}function create_modelSelection_slot(a){let e,n,t;function r(s){a[6](s)}let o={slot:"modelSelection",width:"w-[150px]",listItems:a[4].map(func)};return a[1]!==void 0&&(o.value=a[1]),e=new Combobox({props:o}),binding_callbacks.push(()=>bind(e,"value",r)),{c(){create_component(e.$$.fragment)},l(s){claim_component(e.$$.fragment,s)},m(s,l){mount_component(e,s,l),t=!0},p(s,l){const c={};!n&&l&2&&(n=!0,c.value=s[1],add_flush_callback(()=>n=!1)),e.$set(c)},i(s){t||(transition_in(e.$$.fragment,s),t=!0)},o(s){transition_out(e.$$.fragment,s),t=!1},d(s){destroy_component(e,s)}}}function create_fragment$r(a){let e,n,t,r;n=new PreAnnotation({props:{colorScale:a[3]}});let o=!a[2]&&create_if_block$h(a);return{c(){e=element("div"),create_component(n.$$.fragment),t=space(),o&&o.c(),this.h()},l(s){e=claim_element(s,"DIV",{class:!0});var l=children(e);claim_component(n.$$.fragment,l),t=claim_space(l),o&&o.l(l),l.forEach(detach),this.h()},h(){attr(e,"class","p-2 flex flex-col h-[calc(100vh-200px)]")},m(s,l){insert_hydration(s,e,l),mount_component(n,e,null),append_hydration(e,t),o&&o.m(e,null),r=!0},p(s,[l]){s[2]?o&&(group_outros(),transition_out(o,1,1,()=>{o=null}),check_outros()):o?(o.p(s,l),l&4&&transition_in(o,1)):(o=create_if_block$h(s),o.c(),transition_in(o,1),o.m(e,null))},i(s){r||(transition_in(n.$$.fragment,s),transition_in(o),r=!0)},o(s){transition_out(n.$$.fragment,s),transition_out(o),r=!1},d(s){s&&detach(e),destroy_component(n),o&&o.d()}}}const func=a=>({value:a,label:a});function instance$w(a,e,n){let t;component_subscribe(a,preAnnotationIsActive,i=>n(2,t=i));let r={[GROUND_TRUTH]:[],[PRE_ANNOTATION]:[]},o=[];itemObjects.subscribe(i=>{o=i.map(_=>_.id),n(0,r=sortObjectsByModel(i));const d=i.find(_=>_.highlighted==="self");if(!d)return;const p=document.querySelector(`#${createObjectCardId(d)}`);p&&p.scrollIntoView({behavior:"smooth",block:"start"})});let s=ordinalColorScale(o),l=Object.keys(r).filter(i=>i!==GROUND_TRUTH&&i!==PRE_ANNOTATION),c=Object.keys(r).filter(i=>i!==GROUND_TRUTH&&i!==PRE_ANNOTATION)[0];function f(i,d,p,_){p[_]=i,n(0,r)}function h(i){c=i,n(1,c)}function u(i,d,p,_){p[_]=i,n(0,r)}return[r,c,t,s,l,f,h,u]}class ObjectsInspector extends SvelteComponent{constructor(e){super(),init(this,e,instance$w,create_fragment$r,safe_not_equal,{})}}function create_if_block$g(a){let e,n,t,r=a[0].type+"",o,s,l,c,f,h,u,i,d,p,_,m,g,b,v;function T(O){a[7](O)}function y(O){a[8](O)}function w(O){a[9](O)}let S={};return a[1]!==void 0&&(S.isFormValid=a[1]),a[2]!==void 0&&(S.formInputs=a[2]),a[3]!==void 0&&(S.objectProperties=a[3]),c=new CreateFeatureInputs({props:S}),binding_callbacks.push(()=>bind(c,"isFormValid",T)),binding_callbacks.push(()=>bind(c,"formInputs",y)),binding_callbacks.push(()=>bind(c,"objectProperties",w)),p=new Button({props:{class:"text-white",$$slots:{default:[create_default_slot_1$5]},$$scope:{ctx:a}}}),p.$on("click",a[10]),m=new Button({props:{class:"text-white",type:"submit",disabled:!a[1],$$slots:{default:[create_default_slot$b]},$$scope:{ctx:a}}}),{c(){e=element("form"),n=element("p"),t=text("Save "),o=text(r),s=space(),l=element("div"),create_component(c.$$.fragment),i=space(),d=element("div"),create_component(p.$$.fragment),_=space(),create_component(m.$$.fragment),this.h()},l(O){e=claim_element(O,"FORM",{class:!0});var P=children(e);n=claim_element(P,"P",{});var E=children(n);t=claim_text(E,"Save "),o=claim_text(E,r),E.forEach(detach),s=claim_space(P),l=claim_element(P,"DIV",{class:!0});var A=children(l);claim_component(c.$$.fragment,A),A.forEach(detach),i=claim_space(P),d=claim_element(P,"DIV",{class:!0});var $=children(d);claim_component(p.$$.fragment,$),_=claim_space($),claim_component(m.$$.fragment,$),$.forEach(detach),P.forEach(detach),this.h()},h(){attr(l,"class","max-h-[calc(100vh-250px)] overflow-y-auto flex flex-col gap-4"),attr(d,"class","flex gap-4"),attr(e,"class","flex flex-col gap-4 p-4")},m(O,P){insert_hydration(O,e,P),append_hydration(e,n),append_hydration(n,t),append_hydration(n,o),append_hydration(e,s),append_hydration(e,l),mount_component(c,l,null),append_hydration(e,i),append_hydration(e,d),mount_component(p,d,null),append_hydration(d,_),mount_component(m,d,null),g=!0,b||(v=listen(e,"submit",prevent_default(a[4])),b=!0)},p(O,P){(!g||P&1)&&r!==(r=O[0].type+"")&&set_data(o,r);const E={};!f&&P&2&&(f=!0,E.isFormValid=O[1],add_flush_callback(()=>f=!1)),!h&&P&4&&(h=!0,E.formInputs=O[2],add_flush_callback(()=>h=!1)),!u&&P&8&&(u=!0,E.objectProperties=O[3],add_flush_callback(()=>u=!1)),c.$set(E);const A={};P&8192&&(A.$$scope={dirty:P,ctx:O}),p.$set(A);const $={};P&2&&($.disabled=!O[1]),P&8192&&($.$$scope={dirty:P,ctx:O}),m.$set($)},i(O){g||(transition_in(c.$$.fragment,O),transition_in(p.$$.fragment,O),transition_in(m.$$.fragment,O),g=!0)},o(O){transition_out(c.$$.fragment,O),transition_out(p.$$.fragment,O),transition_out(m.$$.fragment,O),g=!1},d(O){O&&detach(e),destroy_component(c),destroy_component(p),destroy_component(m),b=!1,v()}}}function create_default_slot_1$5(a){let e;return{c(){e=text("Cancel")},l(n){e=claim_text(n,"Cancel")},m(n,t){insert_hydration(n,e,t)},d(n){n&&detach(e)}}}function create_default_slot$b(a){let e;return{c(){e=text("Confirm")},l(n){e=claim_text(n,"Confirm")},m(n,t){insert_hydration(n,e,t)},d(n){n&&detach(e)}}}function create_fragment$q(a){let e,n,t,r,o=a[0].status==="saving"&&create_if_block$g(a);return{c(){o&&o.c(),e=empty()},l(s){o&&o.l(s),e=empty()},m(s,l){o&&o.m(s,l),insert_hydration(s,e,l),n=!0,t||(r=listen(window,"keydown",a[5]),t=!0)},p(s,[l]){s[0].status==="saving"?o?(o.p(s,l),l&1&&transition_in(o,1)):(o=create_if_block$g(s),o.c(),transition_in(o,1),o.m(e.parentNode,e)):o&&(group_outros(),transition_out(o,1,1,()=>{o=null}),check_outros())},i(s){n||(transition_in(o),n=!0)},o(s){transition_out(o),n=!1},d(s){s&&detach(e),o&&o.d(s),t=!1,r()}}}function instance$v(a,e,n){let t,r;component_subscribe(a,itemMetas,m=>n(11,t=m)),component_subscribe(a,lastFrameIndex,m=>n(12,r=m));let{currentTab:o}=e,s,l=!1,c=[],f={};newShape.subscribe(m=>{m&&n(0,s=m)});const h=()=>{const m=mapShapeInputsToFeatures(f,c);itemObjects.update(g=>{if(s.status!=="saving")return g;const b=defineCreatedObject(s,t.type,m,r);return[...g,...b?[b]:[]]});for(let g in f)typeof f[g]=="string"&&addNewInput(t.featuresList,"objects",g,f[g]);newShape.set({status:"none",shouldReset:!0}),canSave.set(!0),n(6,o="objects")};function u(m){m.key==="Escape"&&newShape.set({status:"none",shouldReset:!0})}function i(m){l=m,n(1,l)}function d(m){c=m,n(2,c)}function p(m){f=m,n(3,f)}const _=()=>newShape.set({status:"none",shouldReset:!0});return a.$$set=m=>{"currentTab"in m&&n(6,o=m.currentTab)},[s,l,c,f,h,u,o,i,d,p,_]}class SaveShapeForm extends SvelteComponent{constructor(e){super(),init(this,e,instance$v,create_fragment$q,safe_not_equal,{currentTab:6})}}function create_else_block$3(a){let e,n,t;function r(s){a[6](s)}let o={class:"h-full",$$slots:{default:[create_default_slot$a]},$$scope:{ctx:a}};return a[2]!==void 0&&(o.value=a[2]),e=new Root$2({props:o}),binding_callbacks.push(()=>bind(e,"value",r)),{c(){create_component(e.$$.fragment)},l(s){claim_component(e.$$.fragment,s)},m(s,l){mount_component(e,s,l),t=!0},p(s,l){const c={};l&137&&(c.$$scope={dirty:l,ctx:s}),!n&&l&4&&(n=!0,c.value=s[2],add_flush_callback(()=>n=!1)),e.$set(c)},i(s){t||(transition_in(e.$$.fragment,s),t=!0)},o(s){transition_out(e.$$.fragment,s),t=!1},d(s){destroy_component(e,s)}}}function create_if_block$f(a){let e,n,t;function r(s){a[5](s)}let o={};return a[2]!==void 0&&(o.currentTab=a[2]),e=new SaveShapeForm({props:o}),binding_callbacks.push(()=>bind(e,"currentTab",r)),{c(){create_component(e.$$.fragment)},l(s){claim_component(e.$$.fragment,s)},m(s,l){mount_component(e,s,l),t=!0},p(s,l){const c={};!n&&l&4&&(n=!0,c.currentTab=s[2],add_flush_callback(()=>n=!1)),e.$set(c)},i(s){t||(transition_in(e.$$.fragment,s),t=!0)},o(s){transition_out(e.$$.fragment,s),t=!1},d(s){destroy_component(e,s)}}}function create_default_slot_5$1(a){let e;return{c(){e=text("Objects")},l(n){e=claim_text(n,"Objects")},m(n,t){insert_hydration(n,e,t)},d(n){n&&detach(e)}}}function create_default_slot_4$2(a){let e;return{c(){e=text("Scene")},l(n){e=claim_text(n,"Scene")},m(n,t){insert_hydration(n,e,t)},d(n){n&&detach(e)}}}function create_default_slot_3$3(a){let e,n,t,r;return e=new Tabs_trigger({props:{value:"objects",class:"w-1/2",$$slots:{default:[create_default_slot_5$1]},$$scope:{ctx:a}}}),t=new Tabs_trigger({props:{value:"scene",class:"w-1/2 ",$$slots:{default:[create_default_slot_4$2]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment),n=space(),create_component(t.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(t.$$.fragment,o)},m(o,s){mount_component(e,o,s),insert_hydration(o,n,s),mount_component(t,o,s),r=!0},p(o,s){const l={};s&128&&(l.$$scope={dirty:s,ctx:o}),e.$set(l);const c={};s&128&&(c.$$scope={dirty:s,ctx:o}),t.$set(c)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(t.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(t.$$.fragment,o),r=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(t,o)}}}function create_else_block_2(a){let e,n;return e=new ObjectsInspector({}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_if_block_2$4(a){let e,n,t,r,o,s,l;return n=new Skeleton({props:{class:"h-8 w-full"}}),r=new Skeleton({props:{class:"h-8 w-full"}}),s=new Skeleton({props:{class:"h-8 w-full"}}),{c(){e=element("div"),create_component(n.$$.fragment),t=space(),create_component(r.$$.fragment),o=space(),create_component(s.$$.fragment),this.h()},l(c){e=claim_element(c,"DIV",{class:!0});var f=children(e);claim_component(n.$$.fragment,f),t=claim_space(f),claim_component(r.$$.fragment,f),o=claim_space(f),claim_component(s.$$.fragment,f),f.forEach(detach),this.h()},h(){attr(e,"class","p-4 flex flex-col gap-4")},m(c,f){insert_hydration(c,e,f),mount_component(n,e,null),append_hydration(e,t),mount_component(r,e,null),append_hydration(e,o),mount_component(s,e,null),l=!0},i(c){l||(transition_in(n.$$.fragment,c),transition_in(r.$$.fragment,c),transition_in(s.$$.fragment,c),l=!0)},o(c){transition_out(n.$$.fragment,c),transition_out(r.$$.fragment,c),transition_out(s.$$.fragment,c),l=!1},d(c){c&&detach(e),destroy_component(n),destroy_component(r),destroy_component(s)}}}function create_default_slot_2$3(a){let e,n,t,r;const o=[create_if_block_2$4,create_else_block_2],s=[];function l(c,f){return c[0]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,f){let h=e;e=l(c),e!==h&&(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n||(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function create_else_block_1(a){let e,n;return e=new SceneInspector({}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_if_block_1$7(a){let e,n,t,r,o,s,l;return n=new Skeleton({props:{class:"h-8 w-full"}}),r=new Skeleton({props:{class:"h-8 w-full"}}),s=new Skeleton({props:{class:"h-8 w-full"}}),{c(){e=element("div"),create_component(n.$$.fragment),t=space(),create_component(r.$$.fragment),o=space(),create_component(s.$$.fragment),this.h()},l(c){e=claim_element(c,"DIV",{class:!0});var f=children(e);claim_component(n.$$.fragment,f),t=claim_space(f),claim_component(r.$$.fragment,f),o=claim_space(f),claim_component(s.$$.fragment,f),f.forEach(detach),this.h()},h(){attr(e,"class","p-4 flex flex-col gap-4")},m(c,f){insert_hydration(c,e,f),mount_component(n,e,null),append_hydration(e,t),mount_component(r,e,null),append_hydration(e,o),mount_component(s,e,null),l=!0},i(c){l||(transition_in(n.$$.fragment,c),transition_in(r.$$.fragment,c),transition_in(s.$$.fragment,c),l=!0)},o(c){transition_out(n.$$.fragment,c),transition_out(r.$$.fragment,c),transition_out(s.$$.fragment,c),l=!1},d(c){c&&detach(e),destroy_component(n),destroy_component(r),destroy_component(s)}}}function create_default_slot_1$4(a){let e,n,t,r;const o=[create_if_block_1$7,create_else_block_1],s=[];function l(c,f){return c[0]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,f){let h=e;e=l(c),e!==h&&(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n||(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function create_default_slot$a(a){let e,n,t,r,o,s,l,c,f,h,u,i,d,p;return e=new Tabs_list({props:{class:"h-[48px]",$$slots:{default:[create_default_slot_3$3]},$$scope:{ctx:a}}}),r=new Tabs_content({props:{value:"objects",class:"h-full",$$slots:{default:[create_default_slot_2$3]},$$scope:{ctx:a}}}),s=new Tabs_content({props:{value:"scene",class:"max-h-[calc(100vh-200px)] overflow-y-auto",$$slots:{default:[create_default_slot_1$4]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment),n=space(),t=element("div"),create_component(r.$$.fragment),o=space(),create_component(s.$$.fragment),l=space(),c=element("button"),f=text("SAVE CHANGES"),this.h()},l(_){claim_component(e.$$.fragment,_),n=claim_space(_),t=claim_element(_,"DIV",{class:!0});var m=children(t);claim_component(r.$$.fragment,m),o=claim_space(m),claim_component(s.$$.fragment,m),l=claim_space(m),c=claim_element(m,"BUTTON",{class:!0});var g=children(c);f=claim_text(g,"SAVE CHANGES"),g.forEach(detach),m.forEach(detach),this.h()},h(){c.disabled=h=!a[3],attr(c,"class",u=cn("h-[48px] w-full border-t border-t-primary-light hover:bg-primary-light hover:cursor-pointer bg-slate-50 z-50",{"bg-slate-100 hover:bg-slate-100 pointer-events-none cursor-not-allowed text-slate-500":!a[3]})),attr(t,"class","h-[calc(100%-48px)] flex flex-col justify-between")},m(_,m){mount_component(e,_,m),insert_hydration(_,n,m),insert_hydration(_,t,m),mount_component(r,t,null),append_hydration(t,o),mount_component(s,t,null),append_hydration(t,l),append_hydration(t,c),append_hydration(c,f),i=!0,d||(p=listen(c,"click",a[4]),d=!0)},p(_,m){const g={};m&128&&(g.$$scope={dirty:m,ctx:_}),e.$set(g);const b={};m&129&&(b.$$scope={dirty:m,ctx:_}),r.$set(b);const v={};m&129&&(v.$$scope={dirty:m,ctx:_}),s.$set(v),(!i||m&8&&h!==(h=!_[3]))&&(c.disabled=h),(!i||m&8&&u!==(u=cn("h-[48px] w-full border-t border-t-primary-light hover:bg-primary-light hover:cursor-pointer bg-slate-50 z-50",{"bg-slate-100 hover:bg-slate-100 pointer-events-none cursor-not-allowed text-slate-500":!_[3]})))&&attr(c,"class",u)},i(_){i||(transition_in(e.$$.fragment,_),transition_in(r.$$.fragment,_),transition_in(s.$$.fragment,_),i=!0)},o(_){transition_out(e.$$.fragment,_),transition_out(r.$$.fragment,_),transition_out(s.$$.fragment,_),i=!1},d(_){_&&(detach(n),detach(t)),destroy_component(e,_),destroy_component(r),destroy_component(s),d=!1,p()}}}function create_fragment$p(a){let e,n,t,r;const o=[create_if_block$f,create_else_block$3],s=[];function l(c,f){var h;return((h=c[1])==null?void 0:h.status)==="saving"?0:1}return n=l(a),t=s[n]=o[n](a),{c(){e=element("div"),t.c(),this.h()},l(c){e=claim_element(c,"DIV",{class:!0});var f=children(e);t.l(f),f.forEach(detach),this.h()},h(){attr(e,"class","h-full max-h-screen shadow-sm border-l border-slate-200 bg-slate-100 font-Montserrat")},m(c,f){insert_hydration(c,e,f),s[n].m(e,null),r=!0},p(c,[f]){let h=n;n=l(c),n===h?s[n].p(c,f):(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),t=s[n],t?t.p(c,f):(t=s[n]=o[n](c),t.c()),transition_in(t,1),t.m(e,null))},i(c){r||(transition_in(t),r=!0)},o(c){transition_out(t),r=!1},d(c){c&&detach(e),s[n].d()}}}function instance$u(a,e,n){let{isLoading:t}=e,r,o="objects",s=!1;canSave.subscribe(h=>{n(3,s=h)}),newShape.subscribe(h=>{n(1,r=h)});function l(h){bubble.call(this,a,h)}function c(h){o=h,n(2,o)}function f(h){o=h,n(2,o)}return a.$$set=h=>{"isLoading"in h&&n(0,t=h.isLoading)},[t,r,o,s,l,c,f]}class InspectorInspector extends SvelteComponent{constructor(e){super(),init(this,e,instance$u,create_fragment$p,safe_not_equal,{isLoading:0})}}async function loadEmbeddings(a,e,n){const t={};if(e){const r=await getItemEmbeddings(n,a,e);if(r.embeddings)for(const[o,s]of Object.entries(r.embeddings))try{const l=parse(b64ToBuffer(s.data));t[o]=new ort_minExports.Tensor("float32",l.data,l.shape)}catch(l){console.warn("AnnotationWorkspace.loadModel - Error loading embeddings",l)}}if(Object.keys(t).length===0)throw new Error("No embeddings found");return t}function create_if_block_2$3(a){let e,n,t;function r(s){a[8](s)}let o={message:"Please select your model for interactive segmentation.",choices:a[0],ifNoChoices:""};return a[1]!==void 0&&(o.selected=a[1]),e=new SelectModal({props:o}),binding_callbacks.push(()=>bind(e,"selected",r)),e.$on("confirm",a[3]),{c(){create_component(e.$$.fragment)},l(s){claim_component(e.$$.fragment,s)},m(s,l){mount_component(e,s,l),t=!0},p(s,l){const c={};l&1&&(c.choices=s[0]),!n&&l&2&&(n=!0,c.selected=s[1],add_flush_callback(()=>n=!1)),e.$set(c)},i(s){t||(transition_in(e.$$.fragment,s),t=!0)},o(s){transition_out(e.$$.fragment,s),t=!1},d(s){destroy_component(e,s)}}}function create_if_block_1$6(a){let e,n;return e=new WarningModal({props:{message:"It looks like there is no model for interactive segmentation in your dataset library.",details:"Please refer to our interactive annotation notebook for information on how to export your model to ONNX."}}),e.$on("confirm",a[9]),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_if_block$e(a){let e,n;return e=new ConfirmModal({props:{message:"No embeddings found for model "+a[1]+".",details:"Please refer to our interactive annotation notebook for information on how to compute embeddings on your dataset."}}),e.$on("confirm",a[10]),e.$on("cancel",a[11]),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r&2&&(o.message="No embeddings found for model "+t[1]+"."),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_fragment$o(a){let e,n,t,r,o=a[2]==="selectModel"&&create_if_block_2$3(a),s=a[2]==="noModel"&&create_if_block_1$6(a),l=a[2]==="noEmbeddings"&&create_if_block$e(a);return{c(){o&&o.c(),e=space(),s&&s.c(),n=space(),l&&l.c(),t=empty()},l(c){o&&o.l(c),e=claim_space(c),s&&s.l(c),n=claim_space(c),l&&l.l(c),t=empty()},m(c,f){o&&o.m(c,f),insert_hydration(c,e,f),s&&s.m(c,f),insert_hydration(c,n,f),l&&l.m(c,f),insert_hydration(c,t,f),r=!0},p(c,[f]){c[2]==="selectModel"?o?(o.p(c,f),f&4&&transition_in(o,1)):(o=create_if_block_2$3(c),o.c(),transition_in(o,1),o.m(e.parentNode,e)):o&&(group_outros(),transition_out(o,1,1,()=>{o=null}),check_outros()),c[2]==="noModel"?s?f&4&&transition_in(s,1):(s=create_if_block_1$6(c),s.c(),transition_in(s,1),s.m(n.parentNode,n)):s&&(group_outros(),transition_out(s,1,1,()=>{s=null}),check_outros()),c[2]==="noEmbeddings"?l?(l.p(c,f),f&4&&transition_in(l,1)):(l=create_if_block$e(c),l.c(),transition_in(l,1),l.m(t.parentNode,t)):l&&(group_outros(),transition_out(l,1,1,()=>{l=null}),check_outros())},i(c){r||(transition_in(o),transition_in(s),transition_in(l),r=!0)},o(c){transition_out(o),transition_out(s),transition_out(l),r=!1},d(c){c&&(detach(e),detach(n),detach(t)),o&&o.d(c),s&&s.d(c),l&&l.d(c)}}}function instance$t(a,e,n){let t;component_subscribe(a,selectedTool,g=>n(7,t=g));let{models:r}=e,{currentDatasetId:o}=e,{selectedItemId:s}=e,{embeddings:l}=e,c="none",f;modelsStore.subscribe(g=>{n(2,c=g.currentModalOpen),n(1,f=g.selectedModelName)});const h=()=>{!s||!f||!o||f==="none"||loadEmbeddings(s,f,o).then(g=>{n(4,l=g)}).catch(g=>{modelsStore.update(b=>({...b,currentModalOpen:"noEmbeddings"})),console.error("cannot load Embeddings",g)})},u=new SAM;async function i(){modelsStore.update(g=>({...g,currentModalOpen:"none"})),await u.init("/data/models/"+f),interactiveSegmenterModel.set(u),h()}onMount(async()=>{if(r.length>0){let g=r.filter(b=>b.includes("sam"));g.length==1&&(modelsStore.update(b=>({...b,selectedModelName:g[0]})),await i())}});function d(g){f=g,n(1,f)}const p=()=>modelsStore.update(g=>({...g,currentModalOpen:"none"})),_=()=>modelsStore.update(g=>({...g,currentModalOpen:"selectModel"})),m=()=>modelsStore.update(g=>({...g,currentModalOpen:"none",selectedModelName:"none"}));return a.$$set=g=>{"models"in g&&n(0,r=g.models),"currentDatasetId"in g&&n(5,o=g.currentDatasetId),"selectedItemId"in g&&n(6,s=g.selectedItemId),"embeddings"in g&&n(4,l=g.embeddings)},a.$$.update=()=>{a.$$.dirty&64&&s&&h(),a.$$.dirty&131&&(t!=null&&t.isSmart&&r.length>1&&!f&&modelsStore.update(g=>({...g,currentModalOpen:"selectModel"})),t!=null&&t.isSmart&&r.length==0&&modelsStore.update(g=>({...g,currentModalOpen:"noModel"}))),a.$$.dirty&2&&f&&modelsStore.update(g=>({...g,selectedModelName:f}))},[r,f,c,i,l,o,s,t,d,p,_,m]}class LoadModelModal extends SvelteComponent{constructor(e){super(),init(this,e,instance$t,create_fragment$o,safe_not_equal,{models:0,currentDatasetId:5,selectedItemId:6,embeddings:4})}}var PI_OVER_180=Math.PI/180;function detectBrowser(){return typeof window<"u"&&({}.toString.call(window)==="[object Window]"||{}.toString.call(window)==="[object global]")}const glob=typeof global<"u"?global:typeof window<"u"?window:typeof WorkerGlobalScope<"u"?self:{},Konva$2={_global:glob,version:"8.4.3",isBrowser:detectBrowser(),isUnminified:/param/.test((function(a){}).toString()),dblClickWindow:400,getAngle(a){return Konva$2.angleDeg?a*PI_OVER_180:a},enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,pixelRatio:typeof window<"u"&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return Konva$2.DD.isDragging},isDragReady(){return!!Konva$2.DD.node},releaseCanvasOnDestroy:!0,document:glob.document,_injectGlobal(a){glob.Konva=a}},_registerNode=a=>{Konva$2[a.prototype.getClassName()]=a};Konva$2._injectGlobal(Konva$2);class Transform{constructor(e=[1,0,0,1,0,0]){this.dirty=!1,this.m=e&&e.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new Transform(this.m)}copyInto(e){e.m[0]=this.m[0],e.m[1]=this.m[1],e.m[2]=this.m[2],e.m[3]=this.m[3],e.m[4]=this.m[4],e.m[5]=this.m[5]}point(e){var n=this.m;return{x:n[0]*e.x+n[2]*e.y+n[4],y:n[1]*e.x+n[3]*e.y+n[5]}}translate(e,n){return this.m[4]+=this.m[0]*e+this.m[2]*n,this.m[5]+=this.m[1]*e+this.m[3]*n,this}scale(e,n){return this.m[0]*=e,this.m[1]*=e,this.m[2]*=n,this.m[3]*=n,this}rotate(e){var n=Math.cos(e),t=Math.sin(e),r=this.m[0]*n+this.m[2]*t,o=this.m[1]*n+this.m[3]*t,s=this.m[0]*-t+this.m[2]*n,l=this.m[1]*-t+this.m[3]*n;return this.m[0]=r,this.m[1]=o,this.m[2]=s,this.m[3]=l,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(e,n){var t=this.m[0]+this.m[2]*n,r=this.m[1]+this.m[3]*n,o=this.m[2]+this.m[0]*e,s=this.m[3]+this.m[1]*e;return this.m[0]=t,this.m[1]=r,this.m[2]=o,this.m[3]=s,this}multiply(e){var n=this.m[0]*e.m[0]+this.m[2]*e.m[1],t=this.m[1]*e.m[0]+this.m[3]*e.m[1],r=this.m[0]*e.m[2]+this.m[2]*e.m[3],o=this.m[1]*e.m[2]+this.m[3]*e.m[3],s=this.m[0]*e.m[4]+this.m[2]*e.m[5]+this.m[4],l=this.m[1]*e.m[4]+this.m[3]*e.m[5]+this.m[5];return this.m[0]=n,this.m[1]=t,this.m[2]=r,this.m[3]=o,this.m[4]=s,this.m[5]=l,this}invert(){var e=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),n=this.m[3]*e,t=-this.m[1]*e,r=-this.m[2]*e,o=this.m[0]*e,s=e*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),l=e*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=n,this.m[1]=t,this.m[2]=r,this.m[3]=o,this.m[4]=s,this.m[5]=l,this}getMatrix(){return this.m}decompose(){var e=this.m[0],n=this.m[1],t=this.m[2],r=this.m[3],o=this.m[4],s=this.m[5],l=e*r-n*t;let c={x:o,y:s,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(e!=0||n!=0){var f=Math.sqrt(e*e+n*n);c.rotation=n>0?Math.acos(e/f):-Math.acos(e/f),c.scaleX=f,c.scaleY=l/f,c.skewX=(e*t+n*r)/l,c.skewY=0}else if(t!=0||r!=0){var h=Math.sqrt(t*t+r*r);c.rotation=Math.PI/2-(r>0?Math.acos(-t/h):-Math.acos(t/h)),c.scaleX=l/h,c.scaleY=h,c.skewX=0,c.skewY=(e*t+n*r)/l}return c.rotation=Util._getRotation(c.rotation),c}}var OBJECT_ARRAY="[object Array]",OBJECT_NUMBER="[object Number]",OBJECT_STRING="[object String]",OBJECT_BOOLEAN="[object Boolean]",PI_OVER_DEG180=Math.PI/180,DEG180_OVER_PI=180/Math.PI,HASH$1="#",EMPTY_STRING$1="",ZERO="0",KONVA_WARNING="Konva warning: ",KONVA_ERROR="Konva error: ",RGB_PAREN="rgb(",COLORS={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},RGB_REGEX=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,animQueue=[];const req=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(a){setTimeout(a,60)},Util={_isElement(a){return!!(a&&a.nodeType==1)},_isFunction(a){return!!(a&&a.constructor&&a.call&&a.apply)},_isPlainObject(a){return!!a&&a.constructor===Object},_isArray(a){return Object.prototype.toString.call(a)===OBJECT_ARRAY},_isNumber(a){return Object.prototype.toString.call(a)===OBJECT_NUMBER&&!isNaN(a)&&isFinite(a)},_isString(a){return Object.prototype.toString.call(a)===OBJECT_STRING},_isBoolean(a){return Object.prototype.toString.call(a)===OBJECT_BOOLEAN},isObject(a){return a instanceof Object},isValidSelector(a){if(typeof a!="string")return!1;var e=a[0];return e==="#"||e==="."||e===e.toUpperCase()},_sign(a){return a===0||a>0?1:-1},requestAnimFrame(a){animQueue.push(a),animQueue.length===1&&req(function(){const e=animQueue;animQueue=[],e.forEach(function(n){n()})})},createCanvasElement(){var a=document.createElement("canvas");try{a.style=a.style||{}}catch{}return a},createImageElement(){return document.createElement("img")},_isInDocument(a){for(;a=a.parentNode;)if(a==document)return!0;return!1},_urlToImage(a,e){var n=Util.createImageElement();n.onload=function(){e(n)},n.src=a},_rgbToHex(a,e,n){return((1<<24)+(a<<16)+(e<<8)+n).toString(16).slice(1)},_hexToRgb(a){a=a.replace(HASH$1,EMPTY_STRING$1);var e=parseInt(a,16);return{r:e>>16&255,g:e>>8&255,b:e&255}},getRandomColor(){for(var a=(Math.random()*16777215<<0).toString(16);a.length<6;)a=ZERO+a;return HASH$1+a},getRGB(a){var e;return a in COLORS?(e=COLORS[a],{r:e[0],g:e[1],b:e[2]}):a[0]===HASH$1?this._hexToRgb(a.substring(1)):a.substr(0,4)===RGB_PAREN?(e=RGB_REGEX.exec(a.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA(a){return a=a||"black",Util._namedColorToRBA(a)||Util._hex3ColorToRGBA(a)||Util._hex4ColorToRGBA(a)||Util._hex6ColorToRGBA(a)||Util._hex8ColorToRGBA(a)||Util._rgbColorToRGBA(a)||Util._rgbaColorToRGBA(a)||Util._hslColorToRGBA(a)},_namedColorToRBA(a){var e=COLORS[a.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(a){if(a.indexOf("rgb(")===0){a=a.match(/rgb\(([^)]+)\)/)[1];var e=a.split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(a){if(a.indexOf("rgba(")===0){a=a.match(/rgba\(([^)]+)\)/)[1];var e=a.split(/ *, */).map((n,t)=>n.slice(-1)==="%"?t===3?parseInt(n)/100:parseInt(n)/100*255:Number(n));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(a){if(a[0]==="#"&&a.length===9)return{r:parseInt(a.slice(1,3),16),g:parseInt(a.slice(3,5),16),b:parseInt(a.slice(5,7),16),a:parseInt(a.slice(7,9),16)/255}},_hex6ColorToRGBA(a){if(a[0]==="#"&&a.length===7)return{r:parseInt(a.slice(1,3),16),g:parseInt(a.slice(3,5),16),b:parseInt(a.slice(5,7),16),a:1}},_hex4ColorToRGBA(a){if(a[0]==="#"&&a.length===5)return{r:parseInt(a[1]+a[1],16),g:parseInt(a[2]+a[2],16),b:parseInt(a[3]+a[3],16),a:parseInt(a[4]+a[4],16)/255}},_hex3ColorToRGBA(a){if(a[0]==="#"&&a.length===4)return{r:parseInt(a[1]+a[1],16),g:parseInt(a[2]+a[2],16),b:parseInt(a[3]+a[3],16),a:1}},_hslColorToRGBA(a){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(a)){const[e,...n]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(a),t=Number(n[0])/360,r=Number(n[1])/100,o=Number(n[2])/100;let s,l,c;if(r===0)return c=o*255,{r:Math.round(c),g:Math.round(c),b:Math.round(c),a:1};o<.5?s=o*(1+r):s=o+r-o*r;const f=2*o-s,h=[0,0,0];for(let u=0;u<3;u++)l=t+1/3*-(u-1),l<0&&l++,l>1&&l--,6*l<1?c=f+(s-f)*6*l:2*l<1?c=s:3*l<2?c=f+(s-f)*(2/3-l)*6:c=f,h[u]=c*255;return{r:Math.round(h[0]),g:Math.round(h[1]),b:Math.round(h[2]),a:1}}},haveIntersection(a,e){return!(e.x>a.x+a.width||e.x+e.width<a.x||e.y>a.y+a.height||e.y+e.height<a.y)},cloneObject(a){var e={};for(var n in a)this._isPlainObject(a[n])?e[n]=this.cloneObject(a[n]):this._isArray(a[n])?e[n]=this.cloneArray(a[n]):e[n]=a[n];return e},cloneArray(a){return a.slice(0)},degToRad(a){return a*PI_OVER_DEG180},radToDeg(a){return a*DEG180_OVER_PI},_degToRad(a){return Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),Util.degToRad(a)},_radToDeg(a){return Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),Util.radToDeg(a)},_getRotation(a){return Konva$2.angleDeg?Util.radToDeg(a):a},_capitalize(a){return a.charAt(0).toUpperCase()+a.slice(1)},throw(a){throw new Error(KONVA_ERROR+a)},error(a){console.error(KONVA_ERROR+a)},warn(a){Konva$2.showWarnings&&console.warn(KONVA_WARNING+a)},each(a,e){for(var n in a)e(n,a[n])},_inRange(a,e,n){return e<=a&&a<n},_getProjectionToSegment(a,e,n,t,r,o){var s,l,c,f=(a-n)*(a-n)+(e-t)*(e-t);if(f==0)s=a,l=e,c=(r-n)*(r-n)+(o-t)*(o-t);else{var h=((r-a)*(n-a)+(o-e)*(t-e))/f;h<0?(s=a,l=e,c=(a-r)*(a-r)+(e-o)*(e-o)):h>1?(s=n,l=t,c=(n-r)*(n-r)+(t-o)*(t-o)):(s=a+h*(n-a),l=e+h*(t-e),c=(s-r)*(s-r)+(l-o)*(l-o))}return[s,l,c]},_getProjectionToLine(a,e,n){var t=Util.cloneObject(a),r=Number.MAX_VALUE;return e.forEach(function(o,s){if(!(!n&&s===e.length-1)){var l=e[(s+1)%e.length],c=Util._getProjectionToSegment(o.x,o.y,l.x,l.y,a.x,a.y),f=c[0],h=c[1],u=c[2];u<r&&(t.x=f,t.y=h,r=u)}}),t},_prepareArrayForTween(a,e,n){var t,r=[],o=[];if(a.length>e.length){var s=e;e=a,a=s}for(t=0;t<a.length;t+=2)r.push({x:a[t],y:a[t+1]});for(t=0;t<e.length;t+=2)o.push({x:e[t],y:e[t+1]});var l=[];return o.forEach(function(c){var f=Util._getProjectionToLine(c,r,n);l.push(f.x),l.push(f.y)}),l},_prepareToStringify(a){var e;a.visitedByCircularReferenceRemoval=!0;for(var n in a)if(a.hasOwnProperty(n)&&a[n]&&typeof a[n]=="object"){if(e=Object.getOwnPropertyDescriptor(a,n),a[n].visitedByCircularReferenceRemoval||Util._isElement(a[n]))if(e.configurable)delete a[n];else return null;else if(Util._prepareToStringify(a[n])===null)if(e.configurable)delete a[n];else return null}return delete a.visitedByCircularReferenceRemoval,a},_assign(a,e){for(var n in e)a[n]=e[n];return a},_getFirstPointerId(a){return a.touches?a.changedTouches[0].identifier:a.pointerId||999},releaseCanvas(...a){Konva$2.releaseCanvasOnDestroy&&a.forEach(e=>{e.width=0,e.height=0})},drawRoundedRectPath(a,e,n,t){let r=0,o=0,s=0,l=0;typeof t=="number"?r=o=s=l=Math.min(t,e/2,n/2):(r=Math.min(t[0]||0,e/2,n/2),o=Math.min(t[1]||0,e/2,n/2),l=Math.min(t[2]||0,e/2,n/2),s=Math.min(t[3]||0,e/2,n/2)),a.moveTo(r,0),a.lineTo(e-o,0),a.arc(e-o,o,o,Math.PI*3/2,0,!1),a.lineTo(e,n-l),a.arc(e-l,n-l,l,0,Math.PI/2,!1),a.lineTo(s,n),a.arc(s,n-s,s,Math.PI/2,Math.PI,!1),a.lineTo(0,r),a.arc(r,r,r,Math.PI,Math.PI*3/2,!1)}};function _formatValue(a){return Util._isString(a)?'"'+a+'"':Object.prototype.toString.call(a)==="[object Number]"||Util._isBoolean(a)?a:Object.prototype.toString.call(a)}function RGBComponent(a){return a>255?255:a<0?0:Math.round(a)}function getNumberValidator(){if(Konva$2.isUnminified)return function(a,e){return Util._isNumber(a)||Util.warn(_formatValue(a)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),a}}function getNumberOrArrayOfNumbersValidator(a){if(Konva$2.isUnminified)return function(e,n){let t=Util._isNumber(e),r=Util._isArray(e)&&e.length==a;return!t&&!r&&Util.warn(_formatValue(e)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+a+")"),e}}function getNumberOrAutoValidator(){if(Konva$2.isUnminified)return function(a,e){var n=Util._isNumber(a),t=a==="auto";return n||t||Util.warn(_formatValue(a)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),a}}function getStringValidator(){if(Konva$2.isUnminified)return function(a,e){return Util._isString(a)||Util.warn(_formatValue(a)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),a}}function getStringOrGradientValidator(){if(Konva$2.isUnminified)return function(a,e){const n=Util._isString(a),t=Object.prototype.toString.call(a)==="[object CanvasGradient]"||a&&a.addColorStop;return n||t||Util.warn(_formatValue(a)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),a}}function getNumberArrayValidator(){if(Konva$2.isUnminified)return function(a,e){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&a instanceof n||(Util._isArray(a)?a.forEach(function(t){Util._isNumber(t)||Util.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")}):Util.warn(_formatValue(a)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),a}}function getBooleanValidator(){if(Konva$2.isUnminified)return function(a,e){var n=a===!0||a===!1;return n||Util.warn(_formatValue(a)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),a}}function getComponentValidator(a){if(Konva$2.isUnminified)return function(e,n){return e==null||Util.isObject(e)||Util.warn(_formatValue(e)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+a),e}}var GET="get",SET$1="set";const Factory={addGetterSetter(a,e,n,t,r){Factory.addGetter(a,e,n),Factory.addSetter(a,e,t,r),Factory.addOverloadedGetterSetter(a,e)},addGetter(a,e,n){var t=GET+Util._capitalize(e);a.prototype[t]=a.prototype[t]||function(){var r=this.attrs[e];return r===void 0?n:r}},addSetter(a,e,n,t){var r=SET$1+Util._capitalize(e);a.prototype[r]||Factory.overWriteSetter(a,e,n,t)},overWriteSetter(a,e,n,t){var r=SET$1+Util._capitalize(e);a.prototype[r]=function(o){return n&&o!==void 0&&o!==null&&(o=n.call(this,o,e)),this._setAttr(e,o),t&&t.call(this),this}},addComponentsGetterSetter(a,e,n,t,r){var o=n.length,s=Util._capitalize,l=GET+s(e),c=SET$1+s(e),f,h;a.prototype[l]=function(){var i={};for(f=0;f<o;f++)h=n[f],i[h]=this.getAttr(e+s(h));return i};var u=getComponentValidator(n);a.prototype[c]=function(i){var d=this.attrs[e],p;t&&(i=t.call(this,i)),u&&u.call(this,i,e);for(p in i)i.hasOwnProperty(p)&&this._setAttr(e+s(p),i[p]);return i||n.forEach(_=>{this._setAttr(e+s(_),void 0)}),this._fireChangeEvent(e,d,i),r&&r.call(this),this},Factory.addOverloadedGetterSetter(a,e)},addOverloadedGetterSetter(a,e){var n=Util._capitalize(e),t=SET$1+n,r=GET+n;a.prototype[e]=function(){return arguments.length?(this[t](arguments[0]),this):this[r]()}},addDeprecatedGetterSetter(a,e,n,t){Util.error("Adding deprecated "+e);var r=GET+Util._capitalize(e),o=e+" property is deprecated and will be removed soon. Look at Konva change log for more information.";a.prototype[r]=function(){Util.error(o);var s=this.attrs[e];return s===void 0?n:s},Factory.addSetter(a,e,t,function(){Util.error(o)}),Factory.addOverloadedGetterSetter(a,e)},backCompat(a,e){Util.each(e,function(n,t){var r=a.prototype[t],o=GET+Util._capitalize(n),s=SET$1+Util._capitalize(n);function l(){r.apply(this,arguments),Util.error('"'+n+'" method is deprecated and will be removed soon. Use ""'+t+'" instead.')}a.prototype[n]=l,a.prototype[o]=l,a.prototype[s]=l})},afterSetFilter(){this._filterUpToDate=!1}};function simplifyArray(a){var e=[],n=a.length,t=Util,r,o;for(r=0;r<n;r++)o=a[r],t._isNumber(o)?o=Math.round(o*1e3)/1e3:t._isString(o)||(o=o+""),e.push(o);return e}var COMMA=",",OPEN_PAREN="(",CLOSE_PAREN=")",OPEN_PAREN_BRACKET="([",CLOSE_BRACKET_PAREN="])",SEMICOLON=";",DOUBLE_PAREN="()",EQUALS="=",CONTEXT_METHODS=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"],CONTEXT_PROPERTIES=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"];const traceArrMax=100;class Context{constructor(e){this.canvas=e,Konva$2.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(e){e.fillEnabled()&&this._fill(e)}_fill(e){}strokeShape(e){e.hasStroke()&&this._stroke(e)}_stroke(e){}fillStrokeShape(e){e.attrs.fillAfterStrokeEnabled?(this.strokeShape(e),this.fillShape(e)):(this.fillShape(e),this.strokeShape(e))}getTrace(e,n){var t=this.traceArr,r=t.length,o="",s,l,c,f;for(s=0;s<r;s++)l=t[s],c=l.method,c?(f=l.args,o+=c,e?o+=DOUBLE_PAREN:Util._isArray(f[0])?o+=OPEN_PAREN_BRACKET+f.join(COMMA)+CLOSE_BRACKET_PAREN:(n&&(f=f.map(h=>typeof h=="number"?Math.floor(h):h)),o+=OPEN_PAREN+f.join(COMMA)+CLOSE_PAREN)):(o+=l.property,e||(o+=EQUALS+l.val)),o+=SEMICOLON;return o}clearTrace(){this.traceArr=[]}_trace(e){var n=this.traceArr,t;n.push(e),t=n.length,t>=traceArrMax&&n.shift()}reset(){var e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){var n=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,n.getWidth()/n.pixelRatio,n.getHeight()/n.pixelRatio)}_applyLineCap(e){const n=e.attrs.lineCap;n&&this.setAttr("lineCap",n)}_applyOpacity(e){var n=e.getAbsoluteOpacity();n!==1&&this.setAttr("globalAlpha",n)}_applyLineJoin(e){const n=e.attrs.lineJoin;n&&this.setAttr("lineJoin",n)}setAttr(e,n){this._context[e]=n}arc(e,n,t,r,o,s){this._context.arc(e,n,t,r,o,s)}arcTo(e,n,t,r,o){this._context.arcTo(e,n,t,r,o)}beginPath(){this._context.beginPath()}bezierCurveTo(e,n,t,r,o,s){this._context.bezierCurveTo(e,n,t,r,o,s)}clearRect(e,n,t,r){this._context.clearRect(e,n,t,r)}clip(){this._context.clip()}closePath(){this._context.closePath()}createImageData(e,n){var t=arguments;if(t.length===2)return this._context.createImageData(e,n);if(t.length===1)return this._context.createImageData(e)}createLinearGradient(e,n,t,r){return this._context.createLinearGradient(e,n,t,r)}createPattern(e,n){return this._context.createPattern(e,n)}createRadialGradient(e,n,t,r,o,s){return this._context.createRadialGradient(e,n,t,r,o,s)}drawImage(e,n,t,r,o,s,l,c,f){var h=arguments,u=this._context;h.length===3?u.drawImage(e,n,t):h.length===5?u.drawImage(e,n,t,r,o):h.length===9&&u.drawImage(e,n,t,r,o,s,l,c,f)}ellipse(e,n,t,r,o,s,l,c){this._context.ellipse(e,n,t,r,o,s,l,c)}isPointInPath(e,n,t,r){return t?this._context.isPointInPath(t,e,n,r):this._context.isPointInPath(e,n,r)}fill(e){e?this._context.fill(e):this._context.fill()}fillRect(e,n,t,r){this._context.fillRect(e,n,t,r)}strokeRect(e,n,t,r){this._context.strokeRect(e,n,t,r)}fillText(e,n,t,r){r?this._context.fillText(e,n,t,r):this._context.fillText(e,n,t)}measureText(e){return this._context.measureText(e)}getImageData(e,n,t,r){return this._context.getImageData(e,n,t,r)}lineTo(e,n){this._context.lineTo(e,n)}moveTo(e,n){this._context.moveTo(e,n)}rect(e,n,t,r){this._context.rect(e,n,t,r)}putImageData(e,n,t){this._context.putImageData(e,n,t)}quadraticCurveTo(e,n,t,r){this._context.quadraticCurveTo(e,n,t,r)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,n){this._context.scale(e,n)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):"mozDash"in this._context?this._context.mozDash=e:"webkitLineDash"in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,n,t,r,o,s){this._context.setTransform(e,n,t,r,o,s)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,n,t,r){this._context.strokeText(e,n,t,r)}transform(e,n,t,r,o,s){this._context.transform(e,n,t,r,o,s)}translate(e,n){this._context.translate(e,n)}_enableTrace(){var e=this,n=CONTEXT_METHODS.length,t=this.setAttr,r,o,s=function(l){var c=e[l],f;e[l]=function(){return o=simplifyArray(Array.prototype.slice.call(arguments,0)),f=c.apply(e,arguments),e._trace({method:l,args:o}),f}};for(r=0;r<n;r++)s(CONTEXT_METHODS[r]);e.setAttr=function(){t.apply(e,arguments);var l=arguments[0],c=arguments[1];(l==="shadowOffsetX"||l==="shadowOffsetY"||l==="shadowBlur")&&(c=c/this.canvas.getPixelRatio()),e._trace({property:l,val:c})}}_applyGlobalCompositeOperation(e){const n=e.attrs.globalCompositeOperation;var t=!n||n==="source-over";t||this.setAttr("globalCompositeOperation",n)}}CONTEXT_PROPERTIES.forEach(function(a){Object.defineProperty(Context.prototype,a,{get(){return this._context[a]},set(e){this._context[a]=e}})});class SceneContext extends Context{constructor(e){super(e),this._context=e._canvas.getContext("2d")}_fillColor(e){var n=e.fill();this.setAttr("fillStyle",n),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){var n=e._getLinearGradient();n&&(this.setAttr("fillStyle",n),e._fillFunc(this))}_fillRadialGradient(e){const n=e._getRadialGradient();n&&(this.setAttr("fillStyle",n),e._fillFunc(this))}_fill(e){const n=e.fill(),t=e.getFillPriority();if(n&&t==="color"){this._fillColor(e);return}const r=e.getFillPatternImage();if(r&&t==="pattern"){this._fillPattern(e);return}const o=e.getFillLinearGradientColorStops();if(o&&t==="linear-gradient"){this._fillLinearGradient(e);return}const s=e.getFillRadialGradientColorStops();if(s&&t==="radial-gradient"){this._fillRadialGradient(e);return}n?this._fillColor(e):r?this._fillPattern(e):o?this._fillLinearGradient(e):s&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const n=e.getStrokeLinearGradientStartPoint(),t=e.getStrokeLinearGradientEndPoint(),r=e.getStrokeLinearGradientColorStops(),o=this.createLinearGradient(n.x,n.y,t.x,t.y);if(r){for(var s=0;s<r.length;s+=2)o.addColorStop(r[s],r[s+1]);this.setAttr("strokeStyle",o)}}_stroke(e){var n=e.dash(),t=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!t){this.save();var r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(e),n&&e.dashEnabled()&&(this.setLineDash(n),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");var o=e.getStrokeLinearGradientColorStops();o?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),t||this.restore()}}_applyShadow(e){var n,t,r,o=(n=e.getShadowRGBA())!==null&&n!==void 0?n:"black",s=(t=e.getShadowBlur())!==null&&t!==void 0?t:5,l=(r=e.getShadowOffset())!==null&&r!==void 0?r:{x:0,y:0},c=e.getAbsoluteScale(),f=this.canvas.getPixelRatio(),h=c.x*f,u=c.y*f;this.setAttr("shadowColor",o),this.setAttr("shadowBlur",s*Math.min(Math.abs(h),Math.abs(u))),this.setAttr("shadowOffsetX",l.x*h),this.setAttr("shadowOffsetY",l.y*u)}}class HitContext extends Context{constructor(e){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr("fillStyle",e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){const o=e.getStrokeScaleEnabled();if(!o){this.save();var n=this.getCanvas().getPixelRatio();this.setTransform(n,0,0,n,0,0)}this._applyLineCap(e);var t=e.hitStrokeWidth(),r=t==="auto"?e.strokeWidth():t;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),o||this.restore()}}}var _pixelRatio;function getDevicePixelRatio(){if(_pixelRatio)return _pixelRatio;var a=Util.createCanvasElement(),e=a.getContext("2d");return _pixelRatio=function(){var n=Konva$2._global.devicePixelRatio||1,t=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return n/t}(),Util.releaseCanvas(a),_pixelRatio}class Canvas{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var n=e||{},t=n.pixelRatio||Konva$2.pixelRatio||getDevicePixelRatio();this.pixelRatio=t,this._canvas=Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){var n=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/n,this.getHeight()/n)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";var n=this.pixelRatio,t=this.getContext()._context;t.scale(n,n)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";var n=this.pixelRatio,t=this.getContext()._context;t.scale(n,n)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,n){this.setWidth(e||0),this.setHeight(n||0)}toDataURL(e,n){try{return this._canvas.toDataURL(e,n)}catch{try{return this._canvas.toDataURL()}catch(r){return Util.error("Unable to get data URL. "+r.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}Factory.addGetterSetter(Canvas,"pixelRatio",void 0,getNumberValidator());class SceneCanvas extends Canvas{constructor(e={width:0,height:0}){super(e),this.context=new SceneContext(this),this.setSize(e.width,e.height)}}class HitCanvas extends Canvas{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new HitContext(this),this.setSize(e.width,e.height)}}const DD={get isDragging(){var a=!1;return DD._dragElements.forEach(e=>{e.dragStatus==="dragging"&&(a=!0)}),a},justDragged:!1,get node(){var a;return DD._dragElements.forEach(e=>{a=e.node}),a},_dragElements:new Map,_drag(a){const e=[];DD._dragElements.forEach((n,t)=>{const{node:r}=n,o=r.getStage();o.setPointersPositions(a),n.pointerId===void 0&&(n.pointerId=Util._getFirstPointerId(a));const s=o._changedPointerPositions.find(f=>f.id===n.pointerId);if(s){if(n.dragStatus!=="dragging"){var l=r.dragDistance(),c=Math.max(Math.abs(s.x-n.startPointerPos.x),Math.abs(s.y-n.startPointerPos.y));if(c<l||(r.startDrag({evt:a}),!r.isDragging()))return}r._setDragPosition(a,n),e.push(r)}}),e.forEach(n=>{n.fire("dragmove",{type:"dragmove",target:n,evt:a},!0)})},_endDragBefore(a){const e=[];DD._dragElements.forEach(n=>{const{node:t}=n,r=t.getStage();if(a&&r.setPointersPositions(a),!r._changedPointerPositions.find(l=>l.id===n.pointerId))return;(n.dragStatus==="dragging"||n.dragStatus==="stopped")&&(DD.justDragged=!0,Konva$2._mouseListenClick=!1,Konva$2._touchListenClick=!1,Konva$2._pointerListenClick=!1,n.dragStatus="stopped");const s=n.node.getLayer()||n.node instanceof Konva$2.Stage&&n.node;s&&e.indexOf(s)===-1&&e.push(s)}),e.forEach(n=>{n.draw()})},_endDragAfter(a){DD._dragElements.forEach((e,n)=>{e.dragStatus==="stopped"&&e.node.fire("dragend",{type:"dragend",target:e.node,evt:a},!0),e.dragStatus!=="dragging"&&DD._dragElements.delete(n)})}};Konva$2.isBrowser&&(window.addEventListener("mouseup",DD._endDragBefore,!0),window.addEventListener("touchend",DD._endDragBefore,!0),window.addEventListener("mousemove",DD._drag),window.addEventListener("touchmove",DD._drag),window.addEventListener("mouseup",DD._endDragAfter,!1),window.addEventListener("touchend",DD._endDragAfter,!1));var ABSOLUTE_OPACITY="absoluteOpacity",ALL_LISTENERS="allEventListeners",ABSOLUTE_TRANSFORM="absoluteTransform",ABSOLUTE_SCALE="absoluteScale",CANVAS="canvas",CHANGE="Change",CHILDREN="children",KONVA="konva",LISTENING="listening",MOUSEENTER$1="mouseenter",MOUSELEAVE$1="mouseleave",SET="set",SHAPE="Shape",SPACE$1=" ",STAGE$1="stage",TRANSFORM="transform",UPPER_STAGE="Stage",VISIBLE="visible",TRANSFORM_CHANGE_STR$1=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(SPACE$1);let idCounter$1=1;class Node{constructor(e){this._id=idCounter$1++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(e),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(e){(e===TRANSFORM||e===ABSOLUTE_TRANSFORM)&&this._cache.get(e)?this._cache.get(e).dirty=!0:e?this._cache.delete(e):this._cache.clear()}_getCache(e,n){var t=this._cache.get(e),r=e===TRANSFORM||e===ABSOLUTE_TRANSFORM,o=t===void 0||r&&t.dirty===!0;return o&&(t=n.call(this),this._cache.set(e,t)),t}_calculate(e,n,t){if(!this._attachedDepsListeners.get(e)){const r=n.map(o=>o+"Change.konva").join(SPACE$1);this.on(r,()=>{this._clearCache(e)}),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,t)}_getCanvasCache(){return this._cache.get(CANVAS)}_clearSelfAndDescendantCache(e){this._clearCache(e),e===ABSOLUTE_TRANSFORM&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(CANVAS)){const{scene:e,filter:n,hit:t}=this._cache.get(CANVAS);Util.releaseCanvas(e,n,t),this._cache.delete(CANVAS)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){var n=e||{},t={};(n.x===void 0||n.y===void 0||n.width===void 0||n.height===void 0)&&(t=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()}));var r=Math.ceil(n.width||t.width),o=Math.ceil(n.height||t.height),s=n.pixelRatio,l=n.x===void 0?Math.floor(t.x):n.x,c=n.y===void 0?Math.floor(t.y):n.y,f=n.offset||0,h=n.drawBorder||!1,u=n.hitCanvasPixelRatio||1;if(!r||!o){Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}r+=f*2+1,o+=f*2+1,l-=f,c-=f;var i=new SceneCanvas({pixelRatio:s,width:r,height:o}),d=new SceneCanvas({pixelRatio:s,width:0,height:0}),p=new HitCanvas({pixelRatio:u,width:r,height:o}),_=i.getContext(),m=p.getContext();return p.isCache=!0,i.isCache=!0,this._cache.delete(CANVAS),this._filterUpToDate=!1,n.imageSmoothingEnabled===!1&&(i.getContext()._context.imageSmoothingEnabled=!1,d.getContext()._context.imageSmoothingEnabled=!1),_.save(),m.save(),_.translate(-l,-c),m.translate(-l,-c),this._isUnderCache=!0,this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY),this._clearSelfAndDescendantCache(ABSOLUTE_SCALE),this.drawScene(i,this),this.drawHit(p,this),this._isUnderCache=!1,_.restore(),m.restore(),h&&(_.save(),_.beginPath(),_.rect(0,0,r,o),_.closePath(),_.setAttr("strokeStyle","red"),_.setAttr("lineWidth",5),_.stroke(),_.restore()),this._cache.set(CANVAS,{scene:i,filter:d,hit:p,x:l,y:c}),this._requestDraw(),this}isCached(){return this._cache.has(CANVAS)}getClientRect(e){throw new Error('abstract "getClientRect" method call')}_transformedRect(e,n){var t=[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],r,o,s,l,c=this.getAbsoluteTransform(n);return t.forEach(function(f){var h=c.point(f);r===void 0&&(r=s=h.x,o=l=h.y),r=Math.min(r,h.x),o=Math.min(o,h.y),s=Math.max(s,h.x),l=Math.max(l,h.y)}),{x:r,y:o,width:s-r,height:l-o}}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);const n=this._getCanvasCache();e.translate(n.x,n.y);var t=this._getCachedSceneCanvas(),r=t.pixelRatio;e.drawImage(t._canvas,0,0,t.width/r,t.height/r),e.restore()}_drawCachedHitCanvas(e){var n=this._getCanvasCache(),t=n.hit;e.save(),e.translate(n.x,n.y),e.drawImage(t._canvas,0,0,t.width/t.pixelRatio,t.height/t.pixelRatio),e.restore()}_getCachedSceneCanvas(){var e=this.filters(),n=this._getCanvasCache(),t=n.scene,r=n.filter,o=r.getContext(),s,l,c,f;if(e){if(!this._filterUpToDate){var h=t.pixelRatio;r.setSize(t.width/t.pixelRatio,t.height/t.pixelRatio);try{for(s=e.length,o.clear(),o.drawImage(t._canvas,0,0,t.getWidth()/h,t.getHeight()/h),l=o.getImageData(0,0,r.getWidth(),r.getHeight()),c=0;c<s;c++){if(f=e[c],typeof f!="function"){Util.error("Filter should be type of function, but got "+typeof f+" instead. Please check correct filters");continue}f.call(this,l),o.putImageData(l,0,0)}}catch(u){Util.error("Unable to apply filter. "+u.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return r}return t}on(e,n){if(this._cache&&this._cache.delete(ALL_LISTENERS),arguments.length===3)return this._delegate.apply(this,arguments);var t=e.split(SPACE$1),r=t.length,o,s,l,c,f;for(o=0;o<r;o++)s=t[o],l=s.split("."),c=l[0],f=l[1]||"",this.eventListeners[c]||(this.eventListeners[c]=[]),this.eventListeners[c].push({name:f,handler:n});return this}off(e,n){var t=(e||"").split(SPACE$1),r=t.length,o,s,l,c,f,h;if(this._cache&&this._cache.delete(ALL_LISTENERS),!e)for(s in this.eventListeners)this._off(s);for(o=0;o<r;o++)if(l=t[o],c=l.split("."),f=c[0],h=c[1],f)this.eventListeners[f]&&this._off(f,h,n);else for(s in this.eventListeners)this._off(s,h,n);return this}dispatchEvent(e){var n={target:this,type:e.type,evt:e};return this.fire(e.type,n),this}addEventListener(e,n){return this.on(e,function(t){n.call(this,t.evt)}),this}removeEventListener(e){return this.off(e),this}_delegate(e,n,t){var r=this;this.on(e,function(o){for(var s=o.target.findAncestors(n,!0,r),l=0;l<s.length;l++)o=Util.cloneObject(o),o.currentTarget=s[l],t.call(s[l],o)})}remove(){return this.isDragging()&&this.stopDrag(),DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY),this._clearSelfAndDescendantCache(ABSOLUTE_SCALE),this._clearSelfAndDescendantCache(STAGE$1),this._clearSelfAndDescendantCache(VISIBLE),this._clearSelfAndDescendantCache(LISTENING)}_remove(){this._clearCaches();var e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){var n="get"+Util._capitalize(e);return Util._isFunction(this[n])?this[n]():this.attrs[e]}getAncestors(){for(var e=this.getParent(),n=[];e;)n.push(e),e=e.getParent();return n}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges(()=>{var n,t;if(!e)return this;for(n in e)n!==CHILDREN&&(t=SET+Util._capitalize(n),Util._isFunction(this[t])?this[t](e[n]):this._setAttr(n,e[n]))}),this}isListening(){return this._getCache(LISTENING,this._isListening)}_isListening(e){if(!this.listening())return!1;const t=this.getParent();return t&&t!==e&&this!==e?t._isListening(e):!0}isVisible(){return this._getCache(VISIBLE,this._isVisible)}_isVisible(e){if(!this.visible())return!1;const t=this.getParent();return t&&t!==e&&this!==e?t._isVisible(e):!0}shouldDrawHit(e,n=!1){if(e)return this._isVisible(e)&&this._isListening(e);var t=this.getLayer(),r=!1;DD._dragElements.forEach(s=>{s.dragStatus==="dragging"&&(s.node.nodeType==="Stage"||s.node.getLayer()===t)&&(r=!0)});var o=!n&&!Konva$2.hitOnDragEnabled&&r;return this.isListening()&&this.isVisible()&&!o}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){var e=this.getDepth(),n=this,t=0,r,o,s,l;function c(f){for(r=[],o=f.length,s=0;s<o;s++)l=f[s],t++,l.nodeType!==SHAPE&&(r=r.concat(l.getChildren().slice())),l._id===n._id&&(s=o);r.length>0&&r[0].getDepth()<=e&&c(r)}return n.nodeType!==UPPER_STAGE&&c(n.getStage().getChildren()),t}getDepth(){for(var e=0,n=this.parent;n;)e++,n=n.parent;return e}_batchTransformChanges(e){this._batchingTransformChange=!0,e(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM)),this._needClearTransformCache=!1}setPosition(e){return this._batchTransformChanges(()=>{this.x(e.x),this.y(e.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){if(!this.getStage())return null;var e=this.getStage().getPointerPosition();if(!e)return null;var n=this.getAbsoluteTransform().copy();return n.invert(),n.point(e)}getAbsolutePosition(e){let n=!1,t=this.parent;for(;t;){if(t.isCached()){n=!0;break}t=t.parent}n&&!e&&(e=!0);var r=this.getAbsoluteTransform(e).getMatrix(),o=new Transform,s=this.offset();return o.m=r.slice(),o.translate(s.x,s.y),o.getTranslation()}setAbsolutePosition(e){var n=this._clearTransform();this.attrs.x=n.x,this.attrs.y=n.y,delete n.x,delete n.y,this._clearCache(TRANSFORM);var t=this._getAbsoluteTransform().copy();return t.invert(),t.translate(e.x,e.y),e={x:this.attrs.x+t.getTranslation().x,y:this.attrs.y+t.getTranslation().y},this._setTransform(n),this.setPosition({x:e.x,y:e.y}),this._clearCache(TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM),this}_setTransform(e){var n;for(n in e)this.attrs[n]=e[n]}_clearTransform(){var e={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,e}move(e){var n=e.x,t=e.y,r=this.x(),o=this.y();return n!==void 0&&(r+=n),t!==void 0&&(o+=t),this.setPosition({x:r,y:o}),this}_eachAncestorReverse(e,n){var t=[],r=this.getParent(),o,s;if(!(n&&n._id===this._id)){for(t.unshift(this);r&&(!n||r._id!==n._id);)t.unshift(r),r=r.parent;for(o=t.length,s=0;s<o;s++)e(t[s])}}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return Util.warn("Node has no parent. moveToTop function is ignored."),!1;var e=this.index,n=this.parent.getChildren().length;return e<n-1?(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0):!1}moveUp(){if(!this.parent)return Util.warn("Node has no parent. moveUp function is ignored."),!1;var e=this.index,n=this.parent.getChildren().length;return e<n-1?(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0):!1}moveDown(){if(!this.parent)return Util.warn("Node has no parent. moveDown function is ignored."),!1;var e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0):!1}moveToBottom(){if(!this.parent)return Util.warn("Node has no parent. moveToBottom function is ignored."),!1;var e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1}setZIndex(e){if(!this.parent)return Util.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&Util.warn("Unexpected value "+e+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");var n=this.index;return this.parent.children.splice(n,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(ABSOLUTE_OPACITY,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){var e=this.opacity(),n=this.getParent();return n&&!n._isUnderCache&&(e*=n.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){var e={},n=this.getAttrs(),t,r,o,s,l;e.attrs={};for(t in n)r=n[t],l=Util.isObject(r)&&!Util._isPlainObject(r)&&!Util._isArray(r),!l&&(o=typeof this[t]=="function"&&this[t],delete n[t],s=o?o.call(this):null,n[t]=r,s!==r&&(e.attrs[t]=r));return e.className=this.getClassName(),Util._prepareToStringify(e)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,n,t){var r=[];n&&this._isMatch(e)&&r.push(this);for(var o=this.parent;o;){if(o===t)return r;o._isMatch(e)&&r.push(o),o=o.parent}return r}isAncestorOf(e){return!1}findAncestor(e,n,t){return this.findAncestors(e,n,t)[0]}_isMatch(e){if(!e)return!1;if(typeof e=="function")return e(this);var n=e.replace(/ /g,"").split(","),t=n.length,r,o;for(r=0;r<t;r++)if(o=n[r],Util.isValidSelector(o)||(Util.warn('Selector "'+o+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),Util.warn("Konva is awesome, right?")),o.charAt(0)==="#"){if(this.id()===o.slice(1))return!0}else if(o.charAt(0)==="."){if(this.hasName(o.slice(1)))return!0}else if(this.className===o||this.nodeType===o)return!0;return!1}getLayer(){var e=this.getParent();return e?e.getLayer():null}getStage(){return this._getCache(STAGE$1,this._getStage)}_getStage(){var e=this.getParent();if(e)return e.getStage()}fire(e,n={},t){return n.target=n.target||this,t?this._fireAndBubble(e,n):this._fire(e,n),this}getAbsoluteTransform(e){return e?this._getAbsoluteTransform(e):this._getCache(ABSOLUTE_TRANSFORM,this._getAbsoluteTransform)}_getAbsoluteTransform(e){var n;if(e)return n=new Transform,this._eachAncestorReverse(function(r){var o=r.transformsEnabled();o==="all"?n.multiply(r.getTransform()):o==="position"&&n.translate(r.x()-r.offsetX(),r.y()-r.offsetY())},e),n;n=this._cache.get(ABSOLUTE_TRANSFORM)||new Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(n):n.reset();var t=this.transformsEnabled();if(t==="all")n.multiply(this.getTransform());else if(t==="position"){const r=this.attrs.x||0,o=this.attrs.y||0,s=this.attrs.offsetX||0,l=this.attrs.offsetY||0;n.translate(r-s,o-l)}return n.dirty=!1,n}getAbsoluteScale(e){for(var n=this;n;)n._isUnderCache&&(e=n),n=n.getParent();const r=this.getAbsoluteTransform(e).decompose();return{x:r.scaleX,y:r.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(TRANSFORM,this._getTransform)}_getTransform(){var e,n,t=this._cache.get(TRANSFORM)||new Transform;t.reset();var r=this.x(),o=this.y(),s=Konva$2.getAngle(this.rotation()),l=(e=this.attrs.scaleX)!==null&&e!==void 0?e:1,c=(n=this.attrs.scaleY)!==null&&n!==void 0?n:1,f=this.attrs.skewX||0,h=this.attrs.skewY||0,u=this.attrs.offsetX||0,i=this.attrs.offsetY||0;return(r!==0||o!==0)&&t.translate(r,o),s!==0&&t.rotate(s),(f!==0||h!==0)&&t.skew(f,h),(l!==1||c!==1)&&t.scale(l,c),(u!==0||i!==0)&&t.translate(-1*u,-1*i),t.dirty=!1,t}clone(e){var n=Util.cloneObject(this.attrs),t,r,o,s,l;for(t in e)n[t]=e[t];var c=new this.constructor(n);for(t in this.eventListeners)for(r=this.eventListeners[t],o=r.length,s=0;s<o;s++)l=r[s],l.name.indexOf(KONVA)<0&&(c.eventListeners[t]||(c.eventListeners[t]=[]),c.eventListeners[t].push(l));return c}_toKonvaCanvas(e){e=e||{};var n=this.getClientRect(),t=this.getStage(),r=e.x!==void 0?e.x:Math.floor(n.x),o=e.y!==void 0?e.y:Math.floor(n.y),s=e.pixelRatio||1,l=new SceneCanvas({width:e.width||Math.ceil(n.width)||(t?t.width():0),height:e.height||Math.ceil(n.height)||(t?t.height():0),pixelRatio:s}),c=l.getContext();return e.imageSmoothingEnabled===!1&&(c._context.imageSmoothingEnabled=!1),c.save(),(r||o)&&c.translate(-1*r,-1*o),this.drawScene(l),c.restore(),l}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){e=e||{};var n=e.mimeType||null,t=e.quality||null,r=this._toKonvaCanvas(e).toDataURL(n,t);return e.callback&&e.callback(r),r}toImage(e){return new Promise((n,t)=>{try{const r=e==null?void 0:e.callback;r&&delete e.callback,Util._urlToImage(this.toDataURL(e),function(o){n(o),r==null||r(o)})}catch(r){t(r)}})}toBlob(e){return new Promise((n,t)=>{try{const r=e==null?void 0:e.callback;r&&delete e.callback,this.toCanvas(e).toBlob(o=>{n(o),r==null||r(o)})}catch(r){t(r)}})}setSize(e){return this.width(e.width),this.height(e.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance!==void 0?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():Konva$2.dragDistance}_off(e,n,t){var r=this.eventListeners[e],o,s,l;for(o=0;o<r.length;o++)if(s=r[o].name,l=r[o].handler,(s!=="konva"||n==="konva")&&(!n||s===n)&&(!t||t===l)){if(r.splice(o,1),r.length===0){delete this.eventListeners[e];break}o--}}_fireChangeEvent(e,n,t){this._fire(e+CHANGE,{oldVal:n,newVal:t})}addName(e){if(!this.hasName(e)){var n=this.name(),t=n?n+" "+e:e;this.name(t)}return this}hasName(e){if(!e)return!1;const n=this.name();if(!n)return!1;var t=(n||"").split(/\s/g);return t.indexOf(e)!==-1}removeName(e){var n=(this.name()||"").split(/\s/g),t=n.indexOf(e);return t!==-1&&(n.splice(t,1),this.name(n.join(" "))),this}setAttr(e,n){var t=this[SET+Util._capitalize(e)];return Util._isFunction(t)?t.call(this,n):this._setAttr(e,n),this}_requestDraw(){if(Konva$2.autoDrawEnabled){const e=this.getLayer()||this.getStage();e==null||e.batchDraw()}}_setAttr(e,n){var t=this.attrs[e];t===n&&!Util.isObject(n)||(n==null?delete this.attrs[e]:this.attrs[e]=n,this._shouldFireChangeEvents&&this._fireChangeEvent(e,t,n),this._requestDraw())}_setComponentAttr(e,n,t){var r;t!==void 0&&(r=this.attrs[e],r||(this.attrs[e]=this.getAttr(e)),this.attrs[e][n]=t,this._fireChangeEvent(e,r,t))}_fireAndBubble(e,n,t){n&&this.nodeType===SHAPE&&(n.target=this);var r=(e===MOUSEENTER$1||e===MOUSELEAVE$1)&&(t&&(this===t||this.isAncestorOf&&this.isAncestorOf(t))||this.nodeType==="Stage"&&!t);if(!r){this._fire(e,n);var o=(e===MOUSEENTER$1||e===MOUSELEAVE$1)&&t&&t.isAncestorOf&&t.isAncestorOf(this)&&!t.isAncestorOf(this.parent);(n&&!n.cancelBubble||!n)&&this.parent&&this.parent.isListening()&&!o&&(t&&t.parent?this._fireAndBubble.call(this.parent,e,n,t):this._fireAndBubble.call(this.parent,e,n))}}_getProtoListeners(e){let n=this._cache.get(ALL_LISTENERS);if(!n){n={};let r=Object.getPrototypeOf(this);for(;r;){if(!r.eventListeners){r=Object.getPrototypeOf(r);continue}for(var t in r.eventListeners){const o=r.eventListeners[t],s=n[t]||[];n[t]=o.concat(s)}r=Object.getPrototypeOf(r)}this._cache.set(ALL_LISTENERS,n)}return n[e]}_fire(e,n){n=n||{},n.currentTarget=this,n.type=e;const t=this._getProtoListeners(e);if(t)for(var r=0;r<t.length;r++)t[r].handler.call(this,n);const o=this.eventListeners[e];if(o)for(var r=0;r<o.length;r++)o[r].handler.call(this,n)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(e){var n=e?e.pointerId:void 0,t=this.getStage(),r=this.getAbsolutePosition(),o=t._getPointerById(n)||t._changedPointerPositions[0]||r;DD._dragElements.set(this._id,{node:this,startPointerPos:o,offset:{x:o.x-r.x,y:o.y-r.y},dragStatus:"ready",pointerId:n})}startDrag(e,n=!0){DD._dragElements.has(this._id)||this._createDragElement(e);const t=DD._dragElements.get(this._id);t.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:e&&e.evt},n)}_setDragPosition(e,n){const t=this.getStage()._getPointerById(n.pointerId);if(t){var r={x:t.x-n.offset.x,y:t.y-n.offset.y},o=this.dragBoundFunc();if(o!==void 0){const s=o.call(this,r,e);s?r=s:Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}(!this._lastPos||this._lastPos.x!==r.x||this._lastPos.y!==r.y)&&(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}}stopDrag(e){const n=DD._dragElements.get(this._id);n&&(n.dragStatus="stopped"),DD._endDragBefore(e),DD._endDragAfter(e)}setDraggable(e){this._setAttr("draggable",e),this._dragChange()}isDragging(){const e=DD._dragElements.get(this._id);return e?e.dragStatus==="dragging":!1}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(e){var n=e.evt.button!==void 0,t=!n||Konva$2.dragButtons.indexOf(e.evt.button)>=0;if(t&&!this.isDragging()){var r=!1;DD._dragElements.forEach(o=>{this.isAncestorOf(o.node)&&(r=!0)}),r||this._createDragElement(e)}})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();var e=this.getStage();if(!e)return;const n=DD._dragElements.get(this._id),t=n&&n.dragStatus==="dragging",r=n&&n.dragStatus==="ready";t?this.stopDrag():r&&DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const n=this.getStage();if(!n)return!1;const t={x:-e.x,y:-e.y,width:n.width()+2*e.x,height:n.height()+2*e.y};return Util.haveIntersection(t,this.getClientRect())}static create(e,n){return Util._isString(e)&&(e=JSON.parse(e)),this._createNode(e,n)}static _createNode(e,n){var t=Node.prototype.getClassName.call(e),r=e.children,o,s,l;n&&(e.attrs.container=n),Konva$2[t]||(Util.warn('Can not find a node with class name "'+t+'". Fallback to "Shape".'),t="Shape");const c=Konva$2[t];if(o=new c(e.attrs),r)for(s=r.length,l=0;l<s;l++)o.add(Node._createNode(r[l]));return o}}Node.prototype.nodeType="Node";Node.prototype._attrsAffectingSize=[];Node.prototype.eventListeners={};Node.prototype.on.call(Node.prototype,TRANSFORM_CHANGE_STR$1,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM)});Node.prototype.on.call(Node.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(VISIBLE)});Node.prototype.on.call(Node.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(LISTENING)});Node.prototype.on.call(Node.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY)});const addGetterSetter=Factory.addGetterSetter;addGetterSetter(Node,"zIndex");addGetterSetter(Node,"absolutePosition");addGetterSetter(Node,"position");addGetterSetter(Node,"x",0,getNumberValidator());addGetterSetter(Node,"y",0,getNumberValidator());addGetterSetter(Node,"globalCompositeOperation","source-over",getStringValidator());addGetterSetter(Node,"opacity",1,getNumberValidator());addGetterSetter(Node,"name","",getStringValidator());addGetterSetter(Node,"id","",getStringValidator());addGetterSetter(Node,"rotation",0,getNumberValidator());Factory.addComponentsGetterSetter(Node,"scale",["x","y"]);addGetterSetter(Node,"scaleX",1,getNumberValidator());addGetterSetter(Node,"scaleY",1,getNumberValidator());Factory.addComponentsGetterSetter(Node,"skew",["x","y"]);addGetterSetter(Node,"skewX",0,getNumberValidator());addGetterSetter(Node,"skewY",0,getNumberValidator());Factory.addComponentsGetterSetter(Node,"offset",["x","y"]);addGetterSetter(Node,"offsetX",0,getNumberValidator());addGetterSetter(Node,"offsetY",0,getNumberValidator());addGetterSetter(Node,"dragDistance",null,getNumberValidator());addGetterSetter(Node,"width",0,getNumberValidator());addGetterSetter(Node,"height",0,getNumberValidator());addGetterSetter(Node,"listening",!0,getBooleanValidator());addGetterSetter(Node,"preventDefault",!0,getBooleanValidator());addGetterSetter(Node,"filters",null,function(a){return this._filterUpToDate=!1,a});addGetterSetter(Node,"visible",!0,getBooleanValidator());addGetterSetter(Node,"transformsEnabled","all",getStringValidator());addGetterSetter(Node,"size");addGetterSetter(Node,"dragBoundFunc");addGetterSetter(Node,"draggable",!1,getBooleanValidator());Factory.backCompat(Node,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});let Container$1=class extends Node{constructor(){super(...arguments),this.children=[]}getChildren(e){if(!e)return this.children||[];const n=this.children||[];var t=[];return n.forEach(function(r){e(r)&&t.push(r)}),t}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._requestDraw(),this}add(...e){if(e.length===0)return this;if(e.length>1){for(var n=0;n<e.length;n++)this.add(e[n]);return this}const t=e[0];return t.getParent()?(t.moveTo(this),this):(this._validateAdd(t),t.index=this.getChildren().length,t.parent=this,t._clearCaches(),this.getChildren().push(t),this._fire("add",{child:t}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){var n=this._generalFind(e,!0);return n.length>0?n[0]:void 0}_generalFind(e,n){var t=[];return this._descendants(r=>{const o=r._isMatch(e);return o&&t.push(r),!!(o&&n)}),t}_descendants(e){let n=!1;const t=this.getChildren();for(const r of t){if(n=e(r),n)return!0;if(r.hasChildren()&&(n=r._descendants(e),n))return!0}return!1}toObject(){var e=Node.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(n=>{e.children.push(n.toObject())}),e}isAncestorOf(e){for(var n=e.getParent();n;){if(n._id===this._id)return!0;n=n.getParent()}return!1}clone(e){var n=Node.prototype.clone.call(this,e);return this.getChildren().forEach(function(t){n.add(t.clone())}),n}getAllIntersections(e){var n=[];return this.find("Shape").forEach(function(t){t.isVisible()&&t.intersects(e)&&n.push(t)}),n}_clearSelfAndDescendantCache(e){var n;super._clearSelfAndDescendantCache(e),!this.isCached()&&((n=this.children)===null||n===void 0||n.forEach(function(t){t._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)===null||e===void 0||e.forEach(function(n,t){n.index=t}),this._requestDraw()}drawScene(e,n){var t=this.getLayer(),r=e||t&&t.getCanvas(),o=r&&r.getContext(),s=this._getCanvasCache(),l=s&&s.scene,c=r&&r.isCache;if(!this.isVisible()&&!c)return this;if(l){o.save();var f=this.getAbsoluteTransform(n).getMatrix();o.transform(f[0],f[1],f[2],f[3],f[4],f[5]),this._drawCachedSceneCanvas(o),o.restore()}else this._drawChildren("drawScene",r,n);return this}drawHit(e,n){if(!this.shouldDrawHit(n))return this;var t=this.getLayer(),r=e||t&&t.hitCanvas,o=r&&r.getContext(),s=this._getCanvasCache(),l=s&&s.hit;if(l){o.save();var c=this.getAbsoluteTransform(n).getMatrix();o.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedHitCanvas(o),o.restore()}else this._drawChildren("drawHit",r,n);return this}_drawChildren(e,n,t){var r,o=n&&n.getContext(),s=this.clipWidth(),l=this.clipHeight(),c=this.clipFunc(),f=s&&l||c;const h=t===this;if(f){o.save();var u=this.getAbsoluteTransform(t),i=u.getMatrix();if(o.transform(i[0],i[1],i[2],i[3],i[4],i[5]),o.beginPath(),c)c.call(this,o,this);else{var d=this.clipX(),p=this.clipY();o.rect(d,p,s,l)}o.clip(),i=u.copy().invert().getMatrix(),o.transform(i[0],i[1],i[2],i[3],i[4],i[5])}var _=!h&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";_&&(o.save(),o._applyGlobalCompositeOperation(this)),(r=this.children)===null||r===void 0||r.forEach(function(m){m[e](n,t)}),_&&o.restore(),f&&o.restore()}getClientRect(e){var n;e=e||{};var t=e.skipTransform,r=e.relativeTo,o,s,l,c,f={x:1/0,y:1/0,width:0,height:0},h=this;(n=this.children)===null||n===void 0||n.forEach(function(_){if(_.visible()){var m=_.getClientRect({relativeTo:h,skipShadow:e.skipShadow,skipStroke:e.skipStroke});m.width===0&&m.height===0||(o===void 0?(o=m.x,s=m.y,l=m.x+m.width,c=m.y+m.height):(o=Math.min(o,m.x),s=Math.min(s,m.y),l=Math.max(l,m.x+m.width),c=Math.max(c,m.y+m.height)))}});for(var u=this.find("Shape"),i=!1,d=0;d<u.length;d++){var p=u[d];if(p._isVisible(this)){i=!0;break}}return i&&o!==void 0?f={x:o,y:s,width:l-o,height:c-s}:f={x:0,y:0,width:0,height:0},t?f:this._transformedRect(f,r)}};Factory.addComponentsGetterSetter(Container$1,"clip",["x","y","width","height"]);Factory.addGetterSetter(Container$1,"clipX",void 0,getNumberValidator());Factory.addGetterSetter(Container$1,"clipY",void 0,getNumberValidator());Factory.addGetterSetter(Container$1,"clipWidth",void 0,getNumberValidator());Factory.addGetterSetter(Container$1,"clipHeight",void 0,getNumberValidator());Factory.addGetterSetter(Container$1,"clipFunc");const Captures=new Map,SUPPORT_POINTER_EVENTS=Konva$2._global.PointerEvent!==void 0;function getCapturedShape(a){return Captures.get(a)}function createEvent(a){return{evt:a,pointerId:a.pointerId}}function hasPointerCapture(a,e){return Captures.get(a)===e}function setPointerCapture(a,e){releaseCapture(a),e.getStage()&&(Captures.set(a,e),SUPPORT_POINTER_EVENTS&&e._fire("gotpointercapture",createEvent(new PointerEvent("gotpointercapture"))))}function releaseCapture(a,e){const n=Captures.get(a);if(!n)return;const t=n.getStage();t&&t.content,Captures.delete(a),SUPPORT_POINTER_EVENTS&&n._fire("lostpointercapture",createEvent(new PointerEvent("lostpointercapture")))}var STAGE="Stage",STRING="string",PX="px",MOUSEOUT="mouseout",MOUSELEAVE="mouseleave",MOUSEOVER="mouseover",MOUSEENTER="mouseenter",MOUSEMOVE="mousemove",MOUSEDOWN="mousedown",MOUSEUP="mouseup",POINTERMOVE="pointermove",POINTERDOWN="pointerdown",POINTERUP="pointerup",POINTERCANCEL="pointercancel",LOSTPOINTERCAPTURE="lostpointercapture",POINTEROUT="pointerout",POINTERLEAVE="pointerleave",POINTEROVER="pointerover",POINTERENTER="pointerenter",CONTEXTMENU="contextmenu",TOUCHSTART="touchstart",TOUCHEND="touchend",TOUCHMOVE="touchmove",TOUCHCANCEL="touchcancel",WHEEL="wheel",MAX_LAYERS_NUMBER=5,EVENTS=[[MOUSEENTER,"_pointerenter"],[MOUSEDOWN,"_pointerdown"],[MOUSEMOVE,"_pointermove"],[MOUSEUP,"_pointerup"],[MOUSELEAVE,"_pointerleave"],[TOUCHSTART,"_pointerdown"],[TOUCHMOVE,"_pointermove"],[TOUCHEND,"_pointerup"],[TOUCHCANCEL,"_pointercancel"],[MOUSEOVER,"_pointerover"],[WHEEL,"_wheel"],[CONTEXTMENU,"_contextmenu"],[POINTERDOWN,"_pointerdown"],[POINTERMOVE,"_pointermove"],[POINTERUP,"_pointerup"],[POINTERCANCEL,"_pointercancel"],[LOSTPOINTERCAPTURE,"_lostpointercapture"]];const EVENTS_MAP={mouse:{[POINTEROUT]:MOUSEOUT,[POINTERLEAVE]:MOUSELEAVE,[POINTEROVER]:MOUSEOVER,[POINTERENTER]:MOUSEENTER,[POINTERMOVE]:MOUSEMOVE,[POINTERDOWN]:MOUSEDOWN,[POINTERUP]:MOUSEUP,[POINTERCANCEL]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[POINTEROUT]:"touchout",[POINTERLEAVE]:"touchleave",[POINTEROVER]:"touchover",[POINTERENTER]:"touchenter",[POINTERMOVE]:TOUCHMOVE,[POINTERDOWN]:TOUCHSTART,[POINTERUP]:TOUCHEND,[POINTERCANCEL]:TOUCHCANCEL,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[POINTEROUT]:POINTEROUT,[POINTERLEAVE]:POINTERLEAVE,[POINTEROVER]:POINTEROVER,[POINTERENTER]:POINTERENTER,[POINTERMOVE]:POINTERMOVE,[POINTERDOWN]:POINTERDOWN,[POINTERUP]:POINTERUP,[POINTERCANCEL]:POINTERCANCEL,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},getEventType=a=>a.indexOf("pointer")>=0?"pointer":a.indexOf("touch")>=0?"touch":"mouse",getEventsMap=a=>{const e=getEventType(a);if(e==="pointer")return Konva$2.pointerEventsEnabled&&EVENTS_MAP.pointer;if(e==="touch")return EVENTS_MAP.touch;if(e==="mouse")return EVENTS_MAP.mouse};function checkNoClip(a={}){return(a.clipFunc||a.clipWidth||a.clipHeight)&&Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),a}const NO_POINTERS_MESSAGE="Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);",stages=[];let Stage$1=class extends Container$1{constructor(e){super(checkNoClip(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{checkNoClip(this.attrs)}),this._checkVisibility()}_validateAdd(e){const n=e.getType()==="Layer",t=e.getType()==="FastLayer";n||t||Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const e=this.visible()?"":"none";this.content.style.display=e}setContainer(e){if(typeof e===STRING){if(e.charAt(0)==="."){var n=e.slice(1);e=document.getElementsByClassName(n)[0]}else{var t;e.charAt(0)!=="#"?t=e:t=e.slice(1),e=document.getElementById(t)}if(!e)throw"Can not find container in document with id "+t}return this._setAttr("container",e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){var e=this.children,n=e.length,t;for(t=0;t<n;t++)e[t].clear();return this}clone(e){return e||(e={}),e.container=typeof document<"u"&&document.createElement("div"),Container$1.prototype.clone.call(this,e)}destroy(){super.destroy();var e=this.content;e&&Util._isInDocument(e)&&this.container().removeChild(e);var n=stages.indexOf(this);return n>-1&&stages.splice(n,1),Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(Util.warn(NO_POINTERS_MESSAGE),null)}_getPointerById(e){return this._pointerPositions.find(n=>n.id===e)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){e=e||{},e.x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();var n=new SceneCanvas({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),t=n.getContext()._context,r=this.children;return(e.x||e.y)&&t.translate(-1*e.x,-1*e.y),r.forEach(function(o){if(o.isVisible()){var s=o._toKonvaCanvas(e);t.drawImage(s._canvas,e.x,e.y,s.getWidth()/s.getPixelRatio(),s.getHeight()/s.getPixelRatio())}}),n}getIntersection(e){if(!e)return null;var n=this.children,t=n.length,r=t-1,o;for(o=r;o>=0;o--){const s=n[o].getIntersection(e);if(s)return s}return null}_resizeDOM(){var e=this.width(),n=this.height();this.content&&(this.content.style.width=e+PX,this.content.style.height=n+PX),this.bufferCanvas.setSize(e,n),this.bufferHitCanvas.setSize(e,n),this.children.forEach(t=>{t.setSize({width:e,height:n}),t.draw()})}add(e,...n){if(arguments.length>1){for(var t=0;t<arguments.length;t++)this.add(arguments[t]);return this}super.add(e);var r=this.children.length;return r>MAX_LAYERS_NUMBER&&Util.warn("The stage has "+r+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),e.setSize({width:this.width(),height:this.height()}),e.draw(),Konva$2.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return hasPointerCapture(e,this)}setPointerCapture(e){setPointerCapture(e,this)}releaseCapture(e){releaseCapture(e)}getLayers(){return this.children}_bindContentEvents(){Konva$2.isBrowser&&EVENTS.forEach(([e,n])=>{this.content.addEventListener(e,t=>{this[n](t)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);const n=getEventsMap(e.type);this._fire(n.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const n=getEventsMap(e.type);this._fire(n.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let n=this[e+"targetShape"];return n&&!n.getStage()&&(n=null),n}_pointerleave(e){const n=getEventsMap(e.type),t=getEventType(e.type);if(n){this.setPointersPositions(e);var r=this._getTargetShape(t),o=!DD.isDragging||Konva$2.hitOnDragEnabled;r&&o?(r._fireAndBubble(n.pointerout,{evt:e}),r._fireAndBubble(n.pointerleave,{evt:e}),this._fire(n.pointerleave,{evt:e,target:this,currentTarget:this}),this[t+"targetShape"]=null):o&&(this._fire(n.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(n.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=void 0,this._pointerPositions=[]}}_pointerdown(e){const n=getEventsMap(e.type),t=getEventType(e.type);if(n){this.setPointersPositions(e);var r=!1;this._changedPointerPositions.forEach(o=>{var s=this.getIntersection(o);if(DD.justDragged=!1,Konva$2["_"+t+"ListenClick"]=!0,!(s&&s.isListening()))return;Konva$2.capturePointerEventsEnabled&&s.setPointerCapture(o.id),this[t+"ClickStartShape"]=s,s._fireAndBubble(n.pointerdown,{evt:e,pointerId:o.id}),r=!0;const c=e.type.indexOf("touch")>=0;s.preventDefault()&&e.cancelable&&c&&e.preventDefault()}),r||this._fire(n.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(e){const n=getEventsMap(e.type),t=getEventType(e.type);if(!n)return;DD.isDragging&&DD.node.preventDefault()&&e.cancelable&&e.preventDefault(),this.setPointersPositions(e);var r=!DD.isDragging||Konva$2.hitOnDragEnabled;if(!r)return;var o={};let s=!1;var l=this._getTargetShape(t);this._changedPointerPositions.forEach(c=>{const f=getCapturedShape(c.id)||this.getIntersection(c),h=c.id,u={evt:e,pointerId:h};var i=l!==f;if(i&&l&&(l._fireAndBubble(n.pointerout,Object.assign({},u),f),l._fireAndBubble(n.pointerleave,Object.assign({},u),f)),f){if(o[f._id])return;o[f._id]=!0}f&&f.isListening()?(s=!0,i&&(f._fireAndBubble(n.pointerover,Object.assign({},u),l),f._fireAndBubble(n.pointerenter,Object.assign({},u),l),this[t+"targetShape"]=f),f._fireAndBubble(n.pointermove,Object.assign({},u))):l&&(this._fire(n.pointerover,{evt:e,target:this,currentTarget:this,pointerId:h}),this[t+"targetShape"]=null)}),s||this._fire(n.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const n=getEventsMap(e.type),t=getEventType(e.type);if(!n)return;this.setPointersPositions(e);const r=this[t+"ClickStartShape"],o=this[t+"ClickEndShape"];var s={};let l=!1;this._changedPointerPositions.forEach(c=>{const f=getCapturedShape(c.id)||this.getIntersection(c);if(f){if(f.releaseCapture(c.id),s[f._id])return;s[f._id]=!0}const h=c.id,u={evt:e,pointerId:h};let i=!1;Konva$2["_"+t+"InDblClickWindow"]?(i=!0,clearTimeout(this[t+"DblTimeout"])):DD.justDragged||(Konva$2["_"+t+"InDblClickWindow"]=!0,clearTimeout(this[t+"DblTimeout"])),this[t+"DblTimeout"]=setTimeout(function(){Konva$2["_"+t+"InDblClickWindow"]=!1},Konva$2.dblClickWindow),f&&f.isListening()?(l=!0,this[t+"ClickEndShape"]=f,f._fireAndBubble(n.pointerup,Object.assign({},u)),Konva$2["_"+t+"ListenClick"]&&r&&r===f&&(f._fireAndBubble(n.pointerclick,Object.assign({},u)),i&&o&&o===f&&f._fireAndBubble(n.pointerdblclick,Object.assign({},u)))):(this[t+"ClickEndShape"]=null,Konva$2["_"+t+"ListenClick"]&&this._fire(n.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:h}),i&&this._fire(n.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:h}))}),l||this._fire(n.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),Konva$2["_"+t+"ListenClick"]=!1,e.cancelable&&t!=="touch"&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);var n=this.getIntersection(this.getPointerPosition());n&&n.isListening()?n._fireAndBubble(CONTEXTMENU,{evt:e}):this._fire(CONTEXTMENU,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);var n=this.getIntersection(this.getPointerPosition());n&&n.isListening()?n._fireAndBubble(WHEEL,{evt:e}):this._fire(WHEEL,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const n=getCapturedShape(e.pointerId)||this.getIntersection(this.getPointerPosition());n&&n._fireAndBubble(POINTERUP,createEvent(e)),releaseCapture(e.pointerId)}_lostpointercapture(e){releaseCapture(e.pointerId)}setPointersPositions(e){var n=this._getContentPosition(),t=null,r=null;e=e||window.event,e.touches!==void 0?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,o=>{this._pointerPositions.push({id:o.identifier,x:(o.clientX-n.left)/n.scaleX,y:(o.clientY-n.top)/n.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,o=>{this._changedPointerPositions.push({id:o.identifier,x:(o.clientX-n.left)/n.scaleX,y:(o.clientY-n.top)/n.scaleY})})):(t=(e.clientX-n.left)/n.scaleX,r=(e.clientY-n.top)/n.scaleY,this.pointerPos={x:t,y:r},this._pointerPositions=[{x:t,y:r,id:Util._getFirstPointerId(e)}],this._changedPointerPositions=[{x:t,y:r,id:Util._getFirstPointerId(e)}])}_setPointerPosition(e){Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};var e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!!Konva$2.isBrowser){var e=this.container();if(!e)throw"Stage has no container. A container is required.";e.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),e.appendChild(this.content),this._resizeDOM()}}cache(){return Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(e){e.batchDraw()}),this}};Stage$1.prototype.nodeType=STAGE;_registerNode(Stage$1);Factory.addGetterSetter(Stage$1,"container");var HAS_SHADOW="hasShadow",SHADOW_RGBA="shadowRGBA",patternImage="patternImage",linearGradient="linearGradient",radialGradient="radialGradient";let dummyContext$1;function getDummyContext$1(){return dummyContext$1||(dummyContext$1=Util.createCanvasElement().getContext("2d"),dummyContext$1)}const shapes={};function _fillFunc$2(a){a.fill()}function _strokeFunc$2(a){a.stroke()}function _fillFuncHit(a){a.fill()}function _strokeFuncHit(a){a.stroke()}function _clearHasShadowCache(){this._clearCache(HAS_SHADOW)}function _clearGetShadowRGBACache(){this._clearCache(SHADOW_RGBA)}function _clearFillPatternCache(){this._clearCache(patternImage)}function _clearLinearGradientCache(){this._clearCache(linearGradient)}function _clearRadialGradientCache(){this._clearCache(radialGradient)}let Shape$1=class extends Node{constructor(e){super(e);let n;for(;n=Util.getRandomColor(),!(n&&!(n in shapes)););this.colorKey=n,shapes[n]=this}getContext(){return Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return Util.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(HAS_SHADOW,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(patternImage,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){var e=getDummyContext$1();const n=e.createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(n&&n.setTransform){const t=new Transform;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(Konva$2.getAngle(this.fillPatternRotation())),t.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),t.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const r=t.getMatrix(),o=typeof DOMMatrix>"u"?{a:r[0],b:r[1],c:r[2],d:r[3],e:r[4],f:r[5]}:new DOMMatrix(r);n.setTransform(o)}return n}}_getLinearGradient(){return this._getCache(linearGradient,this.__getLinearGradient)}__getLinearGradient(){var e=this.fillLinearGradientColorStops();if(e){for(var n=getDummyContext$1(),t=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),o=n.createLinearGradient(t.x,t.y,r.x,r.y),s=0;s<e.length;s+=2)o.addColorStop(e[s],e[s+1]);return o}}_getRadialGradient(){return this._getCache(radialGradient,this.__getRadialGradient)}__getRadialGradient(){var e=this.fillRadialGradientColorStops();if(e){for(var n=getDummyContext$1(),t=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),o=n.createRadialGradient(t.x,t.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius()),s=0;s<e.length;s+=2)o.addColorStop(e[s],e[s+1]);return o}}getShadowRGBA(){return this._getCache(SHADOW_RGBA,this._getShadowRGBA)}_getShadowRGBA(){if(this.hasShadow()){var e=Util.colorToRGBA(this.shadowColor());if(e)return"rgba("+e.r+","+e.g+","+e.b+","+e.a*(this.shadowOpacity()||1)+")"}}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!!(this.stroke()||this.strokeLinearGradientColorStops()))}hasHitStroke(){const e=this.hitStrokeWidth();return e==="auto"?this.hasStroke():this.strokeEnabled()&&!!e}intersects(e){var n=this.getStage(),t=n.bufferHitCanvas,r;return t.getContext().clear(),this.drawHit(t,null,!0),r=t.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data,r[3]>0}destroy(){return Node.prototype.destroy.call(this),delete shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){var n;if(!this.getStage()||!((n=this.attrs.perfectDrawEnabled)!==null&&n!==void 0?n:!0))return!1;const r=e||this.hasFill(),o=this.hasStroke(),s=this.getAbsoluteOpacity()!==1;if(r&&o&&s)return!0;const l=this.hasShadow(),c=this.shadowForStrokeEnabled();return!!(r&&o&&l&&c)}setStrokeHitEnabled(e){Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),e?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){var e=this.size();return{x:this._centroid?-e.width/2:0,y:this._centroid?-e.height/2:0,width:e.width,height:e.height}}getClientRect(e={}){const n=e.skipTransform,t=e.relativeTo,r=this.getSelfRect(),s=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,l=r.width+s,c=r.height+s,f=!e.skipShadow&&this.hasShadow(),h=f?this.shadowOffsetX():0,u=f?this.shadowOffsetY():0,i=l+Math.abs(h),d=c+Math.abs(u),p=f&&this.shadowBlur()||0,_=i+p*2,m=d+p*2,g={width:_,height:m,x:-(s/2+p)+Math.min(h,0)+r.x,y:-(s/2+p)+Math.min(u,0)+r.y};return n?g:this._transformedRect(g,t)}drawScene(e,n){var t=this.getLayer(),r=e||t.getCanvas(),o=r.getContext(),s=this._getCanvasCache(),l=this.getSceneFunc(),c=this.hasShadow(),f,h,u,i=r.isCache,d=n===this;if(!this.isVisible()&&!d)return this;if(s){o.save();var p=this.getAbsoluteTransform(n).getMatrix();return o.transform(p[0],p[1],p[2],p[3],p[4],p[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!l)return this;if(o.save(),this._useBufferCanvas()&&!i){f=this.getStage(),h=f.bufferCanvas,u=h.getContext(),u.clear(),u.save(),u._applyLineJoin(this);var _=this.getAbsoluteTransform(n).getMatrix();u.transform(_[0],_[1],_[2],_[3],_[4],_[5]),l.call(this,u,this),u.restore();var m=h.pixelRatio;c&&o._applyShadow(this),o._applyOpacity(this),o._applyGlobalCompositeOperation(this),o.drawImage(h._canvas,0,0,h.width/m,h.height/m)}else{if(o._applyLineJoin(this),!d){var _=this.getAbsoluteTransform(n).getMatrix();o.transform(_[0],_[1],_[2],_[3],_[4],_[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)}c&&o._applyShadow(this),l.call(this,o,this)}return o.restore(),this}drawHit(e,n,t=!1){if(!this.shouldDrawHit(n,t))return this;var r=this.getLayer(),o=e||r.hitCanvas,s=o&&o.getContext(),l=this.hitFunc()||this.sceneFunc(),c=this._getCanvasCache(),f=c&&c.hit;if(this.colorKey||Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),f){s.save();var h=this.getAbsoluteTransform(n).getMatrix();return s.transform(h[0],h[1],h[2],h[3],h[4],h[5]),this._drawCachedHitCanvas(s),s.restore(),this}if(!l)return this;if(s.save(),s._applyLineJoin(this),!(this===n)){var i=this.getAbsoluteTransform(n).getMatrix();s.transform(i[0],i[1],i[2],i[3],i[4],i[5])}return l.call(this,s,this),s.restore(),this}drawHitFromCache(e=0){var n=this._getCanvasCache(),t=this._getCachedSceneCanvas(),r=n.hit,o=r.getContext(),s=r.getWidth(),l=r.getHeight(),c,f,h,u,i,d;o.clear(),o.drawImage(t._canvas,0,0,s,l);try{for(c=o.getImageData(0,0,s,l),f=c.data,h=f.length,u=Util._hexToRgb(this.colorKey),i=0;i<h;i+=4)d=f[i+3],d>e?(f[i]=u.r,f[i+1]=u.g,f[i+2]=u.b,f[i+3]=255):f[i+3]=0;o.putImageData(c,0,0)}catch(p){Util.error("Unable to draw hit graph from cached scene canvas. "+p.message)}return this}hasPointerCapture(e){return hasPointerCapture(e,this)}setPointerCapture(e){setPointerCapture(e,this)}releaseCapture(e){releaseCapture(e)}};Shape$1.prototype._fillFunc=_fillFunc$2;Shape$1.prototype._strokeFunc=_strokeFunc$2;Shape$1.prototype._fillFuncHit=_fillFuncHit;Shape$1.prototype._strokeFuncHit=_strokeFuncHit;Shape$1.prototype._centroid=!1;Shape$1.prototype.nodeType="Shape";_registerNode(Shape$1);Shape$1.prototype.eventListeners={};Shape$1.prototype.on.call(Shape$1.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",_clearHasShadowCache);Shape$1.prototype.on.call(Shape$1.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",_clearGetShadowRGBACache);Shape$1.prototype.on.call(Shape$1.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",_clearFillPatternCache);Shape$1.prototype.on.call(Shape$1.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",_clearLinearGradientCache);Shape$1.prototype.on.call(Shape$1.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",_clearRadialGradientCache);Factory.addGetterSetter(Shape$1,"stroke",void 0,getStringOrGradientValidator());Factory.addGetterSetter(Shape$1,"strokeWidth",2,getNumberValidator());Factory.addGetterSetter(Shape$1,"fillAfterStrokeEnabled",!1);Factory.addGetterSetter(Shape$1,"hitStrokeWidth","auto",getNumberOrAutoValidator());Factory.addGetterSetter(Shape$1,"strokeHitEnabled",!0,getBooleanValidator());Factory.addGetterSetter(Shape$1,"perfectDrawEnabled",!0,getBooleanValidator());Factory.addGetterSetter(Shape$1,"shadowForStrokeEnabled",!0,getBooleanValidator());Factory.addGetterSetter(Shape$1,"lineJoin");Factory.addGetterSetter(Shape$1,"lineCap");Factory.addGetterSetter(Shape$1,"sceneFunc");Factory.addGetterSetter(Shape$1,"hitFunc");Factory.addGetterSetter(Shape$1,"dash");Factory.addGetterSetter(Shape$1,"dashOffset",0,getNumberValidator());Factory.addGetterSetter(Shape$1,"shadowColor",void 0,getStringValidator());Factory.addGetterSetter(Shape$1,"shadowBlur",0,getNumberValidator());Factory.addGetterSetter(Shape$1,"shadowOpacity",1,getNumberValidator());Factory.addComponentsGetterSetter(Shape$1,"shadowOffset",["x","y"]);Factory.addGetterSetter(Shape$1,"shadowOffsetX",0,getNumberValidator());Factory.addGetterSetter(Shape$1,"shadowOffsetY",0,getNumberValidator());Factory.addGetterSetter(Shape$1,"fillPatternImage");Factory.addGetterSetter(Shape$1,"fill",void 0,getStringOrGradientValidator());Factory.addGetterSetter(Shape$1,"fillPatternX",0,getNumberValidator());Factory.addGetterSetter(Shape$1,"fillPatternY",0,getNumberValidator());Factory.addGetterSetter(Shape$1,"fillLinearGradientColorStops");Factory.addGetterSetter(Shape$1,"strokeLinearGradientColorStops");Factory.addGetterSetter(Shape$1,"fillRadialGradientStartRadius",0);Factory.addGetterSetter(Shape$1,"fillRadialGradientEndRadius",0);Factory.addGetterSetter(Shape$1,"fillRadialGradientColorStops");Factory.addGetterSetter(Shape$1,"fillPatternRepeat","repeat");Factory.addGetterSetter(Shape$1,"fillEnabled",!0);Factory.addGetterSetter(Shape$1,"strokeEnabled",!0);Factory.addGetterSetter(Shape$1,"shadowEnabled",!0);Factory.addGetterSetter(Shape$1,"dashEnabled",!0);Factory.addGetterSetter(Shape$1,"strokeScaleEnabled",!0);Factory.addGetterSetter(Shape$1,"fillPriority","color");Factory.addComponentsGetterSetter(Shape$1,"fillPatternOffset",["x","y"]);Factory.addGetterSetter(Shape$1,"fillPatternOffsetX",0,getNumberValidator());Factory.addGetterSetter(Shape$1,"fillPatternOffsetY",0,getNumberValidator());Factory.addComponentsGetterSetter(Shape$1,"fillPatternScale",["x","y"]);Factory.addGetterSetter(Shape$1,"fillPatternScaleX",1,getNumberValidator());Factory.addGetterSetter(Shape$1,"fillPatternScaleY",1,getNumberValidator());Factory.addComponentsGetterSetter(Shape$1,"fillLinearGradientStartPoint",["x","y"]);Factory.addComponentsGetterSetter(Shape$1,"strokeLinearGradientStartPoint",["x","y"]);Factory.addGetterSetter(Shape$1,"fillLinearGradientStartPointX",0);Factory.addGetterSetter(Shape$1,"strokeLinearGradientStartPointX",0);Factory.addGetterSetter(Shape$1,"fillLinearGradientStartPointY",0);Factory.addGetterSetter(Shape$1,"strokeLinearGradientStartPointY",0);Factory.addComponentsGetterSetter(Shape$1,"fillLinearGradientEndPoint",["x","y"]);Factory.addComponentsGetterSetter(Shape$1,"strokeLinearGradientEndPoint",["x","y"]);Factory.addGetterSetter(Shape$1,"fillLinearGradientEndPointX",0);Factory.addGetterSetter(Shape$1,"strokeLinearGradientEndPointX",0);Factory.addGetterSetter(Shape$1,"fillLinearGradientEndPointY",0);Factory.addGetterSetter(Shape$1,"strokeLinearGradientEndPointY",0);Factory.addComponentsGetterSetter(Shape$1,"fillRadialGradientStartPoint",["x","y"]);Factory.addGetterSetter(Shape$1,"fillRadialGradientStartPointX",0);Factory.addGetterSetter(Shape$1,"fillRadialGradientStartPointY",0);Factory.addComponentsGetterSetter(Shape$1,"fillRadialGradientEndPoint",["x","y"]);Factory.addGetterSetter(Shape$1,"fillRadialGradientEndPointX",0);Factory.addGetterSetter(Shape$1,"fillRadialGradientEndPointY",0);Factory.addGetterSetter(Shape$1,"fillPatternRotation",0);Factory.backCompat(Shape$1,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var HASH="#",BEFORE_DRAW="beforeDraw",DRAW="draw",INTERSECTION_OFFSETS=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],INTERSECTION_OFFSETS_LEN=INTERSECTION_OFFSETS.length;let Layer$1=class extends Container$1{constructor(e){super(e),this.canvas=new SceneCanvas,this.hitCanvas=new HitCanvas({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);var n=this.getStage();return n&&n.content&&(n.content.removeChild(this.getNativeCanvasElement()),e<n.children.length-1?n.content.insertBefore(this.getNativeCanvasElement(),n.children[e+1].getCanvas()._canvas):n.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){Node.prototype.moveToTop.call(this);var e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){var e=Node.prototype.moveUp.call(this);if(!e)return!1;var n=this.getStage();return!n||!n.content?!1:(n.content.removeChild(this.getNativeCanvasElement()),this.index<n.children.length-1?n.content.insertBefore(this.getNativeCanvasElement(),n.children[this.index+1].getCanvas()._canvas):n.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(Node.prototype.moveDown.call(this)){var e=this.getStage();if(e){var n=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),n[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(Node.prototype.moveToBottom.call(this)){var e=this.getStage();if(e){var n=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),n[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){var e=this.getNativeCanvasElement();return Node.prototype.remove.call(this),e&&e.parentNode&&Util._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:n}){return this.canvas.setSize(e,n),this.hitCanvas.setSize(e,n),this._setSmoothEnabled(),this}_validateAdd(e){var n=e.getType();n!=="Group"&&n!=="Shape"&&Util.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(e){return e=e||{},e.width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=e.x!==void 0?e.x:this.x(),e.y=e.y!==void 0?e.y:this.y(),Node.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){this.visible()?this.canvas._canvas.style.display="block":this.canvas._canvas.style.display="none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,Util.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;for(var n=1,t=!1;;){for(let r=0;r<INTERSECTION_OFFSETS_LEN;r++){const o=INTERSECTION_OFFSETS[r],s=this._getIntersection({x:e.x+o.x*n,y:e.y+o.y*n}),l=s.shape;if(l)return l;if(t=!!s.antialiased,!s.antialiased)break}if(t)n+=1;else return null}}_getIntersection(e){const n=this.hitCanvas.pixelRatio,t=this.hitCanvas.context.getImageData(Math.round(e.x*n),Math.round(e.y*n),1,1).data,r=t[3];if(r===255){const o=Util._rgbToHex(t[0],t[1],t[2]),s=shapes[HASH+o];return s?{shape:s}:{antialiased:!0}}else if(r>0)return{antialiased:!0};return{}}drawScene(e,n){var t=this.getLayer(),r=e||t&&t.getCanvas();return this._fire(BEFORE_DRAW,{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),Container$1.prototype.drawScene.call(this,r,n),this._fire(DRAW,{node:this}),this}drawHit(e,n){var t=this.getLayer(),r=e||t&&t.hitCanvas;return t&&t.clearBeforeDraw()&&t.getHitCanvas().getContext().clear(),Container$1.prototype.drawHit.call(this,r,n),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!(!this.parent||!this.parent.content)){var e=this.parent,n=!!this.hitCanvas._canvas.parentNode;n?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}}destroy(){return Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};Layer$1.prototype.nodeType="Layer";_registerNode(Layer$1);Factory.addGetterSetter(Layer$1,"imageSmoothingEnabled",!0);Factory.addGetterSetter(Layer$1,"clearBeforeDraw",!0);Factory.addGetterSetter(Layer$1,"hitGraphEnabled",!0,getBooleanValidator());class FastLayer extends Layer$1{constructor(e){super(e),this.listening(!1),Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}FastLayer.prototype.nodeType="FastLayer";_registerNode(FastLayer);let Group$1=class extends Container$1{_validateAdd(e){var n=e.getType();n!=="Group"&&n!=="Shape"&&Util.throw("You may only add groups and shapes to groups.")}};Group$1.prototype.nodeType="Group";_registerNode(Group$1);var now=function(){return glob.performance&&glob.performance.now?function(){return glob.performance.now()}:function(){return new Date().getTime()}}();class Animation{constructor(e,n){this.id=Animation.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:now(),frameRate:0},this.func=e,this.setLayers(n)}setLayers(e){var n=[];return e?e.length>0?n=e:n=[e]:n=[],this.layers=n,this}getLayers(){return this.layers}addLayer(e){var n=this.layers,t=n.length,r;for(r=0;r<t;r++)if(n[r]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){var e=Animation,n=e.animations,t=n.length,r;for(r=0;r<t;r++)if(n[r].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=now(),Animation._addAnimation(this),this}stop(){return Animation._removeAnimation(this),this}_updateFrameObject(e){this.frame.timeDiff=e-this.frame.lastTime,this.frame.lastTime=e,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(e){this.animations.push(e),this._handleAnimation()}static _removeAnimation(e){var n=e.id,t=this.animations,r=t.length,o;for(o=0;o<r;o++)if(t[o].id===n){this.animations.splice(o,1);break}}static _runFrames(){var e={},n=this.animations,t,r,o,s,l,c,f,h,u;for(s=0;s<n.length;s++)if(t=n[s],r=t.layers,o=t.func,t._updateFrameObject(now()),c=r.length,o?u=o.call(t,t.frame)!==!1:u=!0,!!u)for(l=0;l<c;l++)f=r[l],f._id!==void 0&&(e[f._id]=f);for(h in e)e.hasOwnProperty(h)&&e[h].batchDraw()}static _animationLoop(){var e=Animation;e.animations.length?(e._runFrames(),Util.requestAnimFrame(e._animationLoop)):e.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Util.requestAnimFrame(this._animationLoop))}}Animation.animations=[];Animation.animIdCounter=0;Animation.animRunning=!1;var blacklist={node:1,duration:1,easing:1,onFinish:1,yoyo:1},PAUSED=1,PLAYING=2,REVERSING=3,idCounter=0,colorAttrs=["fill","stroke","shadowColor"];class TweenEngine{constructor(e,n,t,r,o,s,l){this.prop=e,this.propFunc=n,this.begin=r,this._pos=r,this.duration=s,this._change=0,this.prevPos=0,this.yoyo=l,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=t,this._change=o-this.begin,this.pause()}fire(e){var n=this[e];n&&n()}setTime(e){e>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return e===void 0&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=PLAYING,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=REVERSING,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(e){this.pause(),this._time=e,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){var e=this.getTimer()-this._startTime;this.state===PLAYING?this.setTime(e):this.state===REVERSING&&this.setTime(this.duration-e)}pause(){this.state=PAUSED,this.fire("onPause")}getTimer(){return new Date().getTime()}}class Tween{constructor(e){var n=this,t=e.node,r=t._id,o,s=e.easing||Easings.Linear,l=!!e.yoyo,c;typeof e.duration>"u"?o=.3:e.duration===0?o=.001:o=e.duration,this.node=t,this._id=idCounter++;var f=t.getLayer()||(t instanceof Konva$2.Stage?t.getLayers():null);f||Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new Animation(function(){n.tween.onEnterFrame()},f),this.tween=new TweenEngine(c,function(h){n._tweenFunc(h)},s,0,1,o*1e3,l),this._addListeners(),Tween.attrs[r]||(Tween.attrs[r]={}),Tween.attrs[r][this._id]||(Tween.attrs[r][this._id]={}),Tween.tweens[r]||(Tween.tweens[r]={});for(c in e)blacklist[c]===void 0&&this._addAttr(c,e[c]);this.reset(),this.onFinish=e.onFinish,this.onReset=e.onReset,this.onUpdate=e.onUpdate}_addAttr(e,n){var t=this.node,r=t._id,o,s,l,c,f,h,u,i;if(l=Tween.tweens[r][e],l&&delete Tween.attrs[r][l][e],o=t.getAttr(e),Util._isArray(n))if(s=[],f=Math.max(n.length,o.length),e==="points"&&n.length!==o.length&&(n.length>o.length?(u=o,o=Util._prepareArrayForTween(o,n,t.closed())):(h=n,n=Util._prepareArrayForTween(n,o,t.closed()))),e.indexOf("fill")===0)for(c=0;c<f;c++)if(c%2===0)s.push(n[c]-o[c]);else{var d=Util.colorToRGBA(o[c]);i=Util.colorToRGBA(n[c]),o[c]=d,s.push({r:i.r-d.r,g:i.g-d.g,b:i.b-d.b,a:i.a-d.a})}else for(c=0;c<f;c++)s.push(n[c]-o[c]);else colorAttrs.indexOf(e)!==-1?(o=Util.colorToRGBA(o),i=Util.colorToRGBA(n),s={r:i.r-o.r,g:i.g-o.g,b:i.b-o.b,a:i.a-o.a}):s=n-o;Tween.attrs[r][this._id][e]={start:o,diff:s,end:n,trueEnd:h,trueStart:u},Tween.tweens[r][e]=this._id}_tweenFunc(e){var n=this.node,t=Tween.attrs[n._id][this._id],r,o,s,l,c,f,h,u;for(r in t){if(o=t[r],s=o.start,l=o.diff,u=o.end,Util._isArray(s))if(c=[],h=Math.max(s.length,u.length),r.indexOf("fill")===0)for(f=0;f<h;f++)f%2===0?c.push((s[f]||0)+l[f]*e):c.push("rgba("+Math.round(s[f].r+l[f].r*e)+","+Math.round(s[f].g+l[f].g*e)+","+Math.round(s[f].b+l[f].b*e)+","+(s[f].a+l[f].a*e)+")");else for(f=0;f<h;f++)c.push((s[f]||0)+l[f]*e);else colorAttrs.indexOf(r)!==-1?c="rgba("+Math.round(s.r+l.r*e)+","+Math.round(s.g+l.g*e)+","+Math.round(s.b+l.b*e)+","+(s.a+l.a*e)+")":c=s+l*e;n.setAttr(r,c)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var e=this.node,n=Tween.attrs[e._id][this._id];n.points&&n.points.trueEnd&&e.setAttr("points",n.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var e=this.node,n=Tween.attrs[e._id][this._id];n.points&&n.points.trueStart&&e.points(n.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(e){return this.tween.seek(e*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var e=this.node._id,n=this._id,t=Tween.tweens[e],r;this.pause();for(r in t)delete Tween.tweens[e][r];delete Tween.attrs[e][n]}}Tween.attrs={};Tween.tweens={};Node.prototype.to=function(a){var e=a.onFinish;a.node=this,a.onFinish=function(){this.destroy(),e&&e()};var n=new Tween(a);n.play()};const Easings={BackEaseIn(a,e,n,t){var r=1.70158;return n*(a/=t)*a*((r+1)*a-r)+e},BackEaseOut(a,e,n,t){var r=1.70158;return n*((a=a/t-1)*a*((r+1)*a+r)+1)+e},BackEaseInOut(a,e,n,t){var r=1.70158;return(a/=t/2)<1?n/2*(a*a*(((r*=1.525)+1)*a-r))+e:n/2*((a-=2)*a*(((r*=1.525)+1)*a+r)+2)+e},ElasticEaseIn(a,e,n,t,r,o){var s=0;return a===0?e:(a/=t)===1?e+n:(o||(o=t*.3),!r||r<Math.abs(n)?(r=n,s=o/4):s=o/(2*Math.PI)*Math.asin(n/r),-(r*Math.pow(2,10*(a-=1))*Math.sin((a*t-s)*(2*Math.PI)/o))+e)},ElasticEaseOut(a,e,n,t,r,o){var s=0;return a===0?e:(a/=t)===1?e+n:(o||(o=t*.3),!r||r<Math.abs(n)?(r=n,s=o/4):s=o/(2*Math.PI)*Math.asin(n/r),r*Math.pow(2,-10*a)*Math.sin((a*t-s)*(2*Math.PI)/o)+n+e)},ElasticEaseInOut(a,e,n,t,r,o){var s=0;return a===0?e:(a/=t/2)===2?e+n:(o||(o=t*(.3*1.5)),!r||r<Math.abs(n)?(r=n,s=o/4):s=o/(2*Math.PI)*Math.asin(n/r),a<1?-.5*(r*Math.pow(2,10*(a-=1))*Math.sin((a*t-s)*(2*Math.PI)/o))+e:r*Math.pow(2,-10*(a-=1))*Math.sin((a*t-s)*(2*Math.PI)/o)*.5+n+e)},BounceEaseOut(a,e,n,t){return(a/=t)<1/2.75?n*(7.5625*a*a)+e:a<2/2.75?n*(7.5625*(a-=1.5/2.75)*a+.75)+e:a<2.5/2.75?n*(7.5625*(a-=2.25/2.75)*a+.9375)+e:n*(7.5625*(a-=2.625/2.75)*a+.984375)+e},BounceEaseIn(a,e,n,t){return n-Easings.BounceEaseOut(t-a,0,n,t)+e},BounceEaseInOut(a,e,n,t){return a<t/2?Easings.BounceEaseIn(a*2,0,n,t)*.5+e:Easings.BounceEaseOut(a*2-t,0,n,t)*.5+n*.5+e},EaseIn(a,e,n,t){return n*(a/=t)*a+e},EaseOut(a,e,n,t){return-n*(a/=t)*(a-2)+e},EaseInOut(a,e,n,t){return(a/=t/2)<1?n/2*a*a+e:-n/2*(--a*(a-2)-1)+e},StrongEaseIn(a,e,n,t){return n*(a/=t)*a*a*a*a+e},StrongEaseOut(a,e,n,t){return n*((a=a/t-1)*a*a*a*a+1)+e},StrongEaseInOut(a,e,n,t){return(a/=t/2)<1?n/2*a*a*a*a*a+e:n/2*((a-=2)*a*a*a*a+2)+e},Linear(a,e,n,t){return n*a/t+e}},Konva$1=Util._assign(Konva$2,{Util,Transform,Node,Container:Container$1,Stage:Stage$1,stages,Layer:Layer$1,FastLayer,Group:Group$1,DD,Shape:Shape$1,shapes,Animation,Tween,Easings,Context,Canvas});class Arc extends Shape$1{_sceneFunc(e){var n=Konva$2.getAngle(this.angle()),t=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,n,t),e.arc(0,0,this.innerRadius(),n,0,!t),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){const e=this.innerRadius(),n=this.outerRadius(),t=this.clockwise(),r=Konva$2.getAngle(t?360-this.angle():this.angle()),o=Math.cos(Math.min(r,Math.PI)),s=1,l=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),c=Math.sin(Math.min(r,Math.PI/2)),f=o*(o>0?e:n),h=s*n,u=l*(l>0?e:n),i=c*(c>0?n:e);return{x:f,y:t?-1*i:u,width:h-f,height:i-u}}}Arc.prototype._centroid=!0;Arc.prototype.className="Arc";Arc.prototype._attrsAffectingSize=["innerRadius","outerRadius"];_registerNode(Arc);Factory.addGetterSetter(Arc,"innerRadius",0,getNumberValidator());Factory.addGetterSetter(Arc,"outerRadius",0,getNumberValidator());Factory.addGetterSetter(Arc,"angle",0,getNumberValidator());Factory.addGetterSetter(Arc,"clockwise",!1,getBooleanValidator());function getControlPoints(a,e,n,t,r,o,s){var l=Math.sqrt(Math.pow(n-a,2)+Math.pow(t-e,2)),c=Math.sqrt(Math.pow(r-n,2)+Math.pow(o-t,2)),f=s*l/(l+c),h=s*c/(l+c),u=n-f*(r-a),i=t-f*(o-e),d=n+h*(r-a),p=t+h*(o-e);return[u,i,d,p]}function expandPoints(a,e){var n=a.length,t=[],r,o;for(r=2;r<n-2;r+=2)o=getControlPoints(a[r-2],a[r-1],a[r],a[r+1],a[r+2],a[r+3],e),!isNaN(o[0])&&(t.push(o[0]),t.push(o[1]),t.push(a[r]),t.push(a[r+1]),t.push(o[2]),t.push(o[3]));return t}let Line$1=class extends Shape$1{constructor(e){super(e),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(e){var n=this.points(),t=n.length,r=this.tension(),o=this.closed(),s=this.bezier(),l,c,f;if(t){if(e.beginPath(),e.moveTo(n[0],n[1]),r!==0&&t>4){for(l=this.getTensionPoints(),c=l.length,f=o?0:4,o||e.quadraticCurveTo(l[0],l[1],l[2],l[3]);f<c-2;)e.bezierCurveTo(l[f++],l[f++],l[f++],l[f++],l[f++],l[f++]);o||e.quadraticCurveTo(l[c-2],l[c-1],n[t-2],n[t-1])}else if(s)for(f=2;f<t;)e.bezierCurveTo(n[f++],n[f++],n[f++],n[f++],n[f++],n[f++]);else for(f=2;f<t;f+=2)e.lineTo(n[f],n[f+1]);o?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():expandPoints(this.points(),this.tension())}_getTensionPointsClosed(){var e=this.points(),n=e.length,t=this.tension(),r=getControlPoints(e[n-2],e[n-1],e[0],e[1],e[2],e[3],t),o=getControlPoints(e[n-4],e[n-3],e[n-2],e[n-1],e[0],e[1],t),s=expandPoints(e,t),l=[r[2],r[3]].concat(s).concat([o[0],o[1],e[n-2],e[n-1],o[2],o[3],r[0],r[1],e[0],e[1]]);return l}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){var e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};this.tension()!==0?e=[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]]:e=this.points();for(var n=e[0],t=e[0],r=e[1],o=e[1],s,l,c=0;c<e.length/2;c++)s=e[c*2],l=e[c*2+1],n=Math.min(n,s),t=Math.max(t,s),r=Math.min(r,l),o=Math.max(o,l);return{x:n,y:r,width:t-n,height:o-r}}};Line$1.prototype.className="Line";Line$1.prototype._attrsAffectingSize=["points","bezier","tension"];_registerNode(Line$1);Factory.addGetterSetter(Line$1,"closed",!1);Factory.addGetterSetter(Line$1,"bezier",!1);Factory.addGetterSetter(Line$1,"tension",0,getNumberValidator());Factory.addGetterSetter(Line$1,"points",[],getNumberArrayValidator());class Path extends Shape$1{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this.dataArray=Path.parsePathData(this.data()),this.pathLength=0;for(var n=0;n<this.dataArray.length;++n)this.pathLength+=this.dataArray[n].pathLength;this.on("dataChange.konva",function(){this.dataArray=Path.parsePathData(this.data()),this.pathLength=0;for(var t=0;t<this.dataArray.length;++t)this.pathLength+=this.dataArray[t].pathLength})}_sceneFunc(e){var n=this.dataArray;e.beginPath();for(var t=!1,r=0;r<n.length;r++){var o=n[r].command,s=n[r].points;switch(o){case"L":e.lineTo(s[0],s[1]);break;case"M":e.moveTo(s[0],s[1]);break;case"C":e.bezierCurveTo(s[0],s[1],s[2],s[3],s[4],s[5]);break;case"Q":e.quadraticCurveTo(s[0],s[1],s[2],s[3]);break;case"A":var l=s[0],c=s[1],f=s[2],h=s[3],u=s[4],i=s[5],d=s[6],p=s[7],_=f>h?f:h,m=f>h?1:f/h,g=f>h?h/f:1;e.translate(l,c),e.rotate(d),e.scale(m,g),e.arc(0,0,_,u,u+i,1-p),e.scale(1/m,1/g),e.rotate(-d),e.translate(-l,-c);break;case"z":t=!0,e.closePath();break}}!t&&!this.hasFill()?e.strokeShape(this):e.fillStrokeShape(this)}getSelfRect(){var e=[];this.dataArray.forEach(function(f){if(f.command==="A"){var h=f.points[4],u=f.points[5],i=f.points[4]+u,d=Math.PI/180;if(Math.abs(h-i)<d&&(d=Math.abs(h-i)),u<0)for(let p=h-d;p>i;p-=d){const _=Path.getPointOnEllipticalArc(f.points[0],f.points[1],f.points[2],f.points[3],p,0);e.push(_.x,_.y)}else for(let p=h+d;p<i;p+=d){const _=Path.getPointOnEllipticalArc(f.points[0],f.points[1],f.points[2],f.points[3],p,0);e.push(_.x,_.y)}}else if(f.command==="C")for(let p=0;p<=1;p+=.01){const _=Path.getPointOnCubicBezier(p,f.start.x,f.start.y,f.points[0],f.points[1],f.points[2],f.points[3],f.points[4],f.points[5]);e.push(_.x,_.y)}else e=e.concat(f.points)});for(var n=e[0],t=e[0],r=e[1],o=e[1],s,l,c=0;c<e.length/2;c++)s=e[c*2],l=e[c*2+1],isNaN(s)||(n=Math.min(n,s),t=Math.max(t,s)),isNaN(l)||(r=Math.min(r,l),o=Math.max(o,l));return{x:n,y:r,width:t-n,height:o-r}}getLength(){return this.pathLength}getPointAtLength(e){var n,t=0,r=this.dataArray.length;if(!r)return null;for(;t<r&&e>this.dataArray[t].pathLength;)e-=this.dataArray[t].pathLength,++t;if(t===r)return n=this.dataArray[t-1].points.slice(-2),{x:n[0],y:n[1]};if(e<.01)return n=this.dataArray[t].points.slice(0,2),{x:n[0],y:n[1]};var o=this.dataArray[t],s=o.points;switch(o.command){case"L":return Path.getPointOnLine(e,o.start.x,o.start.y,s[0],s[1]);case"C":return Path.getPointOnCubicBezier(e/o.pathLength,o.start.x,o.start.y,s[0],s[1],s[2],s[3],s[4],s[5]);case"Q":return Path.getPointOnQuadraticBezier(e/o.pathLength,o.start.x,o.start.y,s[0],s[1],s[2],s[3]);case"A":var l=s[0],c=s[1],f=s[2],h=s[3],u=s[4],i=s[5],d=s[6];return u+=i*e/o.pathLength,Path.getPointOnEllipticalArc(l,c,f,h,u,d)}return null}static getLineLength(e,n,t,r){return Math.sqrt((t-e)*(t-e)+(r-n)*(r-n))}static getPointOnLine(e,n,t,r,o,s,l){s===void 0&&(s=n),l===void 0&&(l=t);var c=(o-t)/(r-n+1e-8),f=Math.sqrt(e*e/(1+c*c));r<n&&(f*=-1);var h=c*f,u;if(r===n)u={x:s,y:l+h};else if((l-t)/(s-n+1e-8)===c)u={x:s+f,y:l+h};else{var i,d,p=this.getLineLength(n,t,r,o),_=(s-n)*(r-n)+(l-t)*(o-t);_=_/(p*p),i=n+_*(r-n),d=t+_*(o-t);var m=this.getLineLength(s,l,i,d),g=Math.sqrt(e*e-m*m);f=Math.sqrt(g*g/(1+c*c)),r<n&&(f*=-1),h=c*f,u={x:i+f,y:d+h}}return u}static getPointOnCubicBezier(e,n,t,r,o,s,l,c,f){function h(m){return m*m*m}function u(m){return 3*m*m*(1-m)}function i(m){return 3*m*(1-m)*(1-m)}function d(m){return(1-m)*(1-m)*(1-m)}var p=c*h(e)+s*u(e)+r*i(e)+n*d(e),_=f*h(e)+l*u(e)+o*i(e)+t*d(e);return{x:p,y:_}}static getPointOnQuadraticBezier(e,n,t,r,o,s,l){function c(d){return d*d}function f(d){return 2*d*(1-d)}function h(d){return(1-d)*(1-d)}var u=s*c(e)+r*f(e)+n*h(e),i=l*c(e)+o*f(e)+t*h(e);return{x:u,y:i}}static getPointOnEllipticalArc(e,n,t,r,o,s){var l=Math.cos(s),c=Math.sin(s),f={x:t*Math.cos(o),y:r*Math.sin(o)};return{x:e+(f.x*l-f.y*c),y:n+(f.x*c+f.y*l)}}static parsePathData(e){if(!e)return[];var n=e,t=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];n=n.replace(new RegExp(" ","g"),",");for(var r=0;r<t.length;r++)n=n.replace(new RegExp(t[r],"g"),"|"+t[r]);var o=n.split("|"),s=[],l=[],c=0,f=0,h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,u;for(r=1;r<o.length;r++){var i=o[r],d=i.charAt(0);for(i=i.slice(1),l.length=0;u=h.exec(i);)l.push(u[0]);for(var p=[],_=0,m=l.length;_<m;_++){if(l[_]==="00"){p.push(0,0);continue}var g=parseFloat(l[_]);isNaN(g)?p.push(0):p.push(g)}for(;p.length>0&&!isNaN(p[0]);){var b=null,v=[],T=c,y=f,w,S,O,P,E,A,$,k,D,I;switch(d){case"l":c+=p.shift(),f+=p.shift(),b="L",v.push(c,f);break;case"L":c=p.shift(),f=p.shift(),v.push(c,f);break;case"m":var C=p.shift(),L=p.shift();if(c+=C,f+=L,b="M",s.length>2&&s[s.length-1].command==="z"){for(var K=s.length-2;K>=0;K--)if(s[K].command==="M"){c=s[K].points[0]+C,f=s[K].points[1]+L;break}}v.push(c,f),d="l";break;case"M":c=p.shift(),f=p.shift(),b="M",v.push(c,f),d="L";break;case"h":c+=p.shift(),b="L",v.push(c,f);break;case"H":c=p.shift(),b="L",v.push(c,f);break;case"v":f+=p.shift(),b="L",v.push(c,f);break;case"V":f=p.shift(),b="L",v.push(c,f);break;case"C":v.push(p.shift(),p.shift(),p.shift(),p.shift()),c=p.shift(),f=p.shift(),v.push(c,f);break;case"c":v.push(c+p.shift(),f+p.shift(),c+p.shift(),f+p.shift()),c+=p.shift(),f+=p.shift(),b="C",v.push(c,f);break;case"S":S=c,O=f,w=s[s.length-1],w.command==="C"&&(S=c+(c-w.points[2]),O=f+(f-w.points[3])),v.push(S,O,p.shift(),p.shift()),c=p.shift(),f=p.shift(),b="C",v.push(c,f);break;case"s":S=c,O=f,w=s[s.length-1],w.command==="C"&&(S=c+(c-w.points[2]),O=f+(f-w.points[3])),v.push(S,O,c+p.shift(),f+p.shift()),c+=p.shift(),f+=p.shift(),b="C",v.push(c,f);break;case"Q":v.push(p.shift(),p.shift()),c=p.shift(),f=p.shift(),v.push(c,f);break;case"q":v.push(c+p.shift(),f+p.shift()),c+=p.shift(),f+=p.shift(),b="Q",v.push(c,f);break;case"T":S=c,O=f,w=s[s.length-1],w.command==="Q"&&(S=c+(c-w.points[0]),O=f+(f-w.points[1])),c=p.shift(),f=p.shift(),b="Q",v.push(S,O,c,f);break;case"t":S=c,O=f,w=s[s.length-1],w.command==="Q"&&(S=c+(c-w.points[0]),O=f+(f-w.points[1])),c+=p.shift(),f+=p.shift(),b="Q",v.push(S,O,c,f);break;case"A":P=p.shift(),E=p.shift(),A=p.shift(),$=p.shift(),k=p.shift(),D=c,I=f,c=p.shift(),f=p.shift(),b="A",v=this.convertEndpointToCenterParameterization(D,I,c,f,$,k,P,E,A);break;case"a":P=p.shift(),E=p.shift(),A=p.shift(),$=p.shift(),k=p.shift(),D=c,I=f,c+=p.shift(),f+=p.shift(),b="A",v=this.convertEndpointToCenterParameterization(D,I,c,f,$,k,P,E,A);break}s.push({command:b||d,points:v,start:{x:T,y},pathLength:this.calcLength(T,y,b||d,v)})}(d==="z"||d==="Z")&&s.push({command:"z",points:[],start:void 0,pathLength:0})}return s}static calcLength(e,n,t,r){var o,s,l,c,f=Path;switch(t){case"L":return f.getLineLength(e,n,r[0],r[1]);case"C":for(o=0,s=f.getPointOnCubicBezier(0,e,n,r[0],r[1],r[2],r[3],r[4],r[5]),c=.01;c<=1;c+=.01)l=f.getPointOnCubicBezier(c,e,n,r[0],r[1],r[2],r[3],r[4],r[5]),o+=f.getLineLength(s.x,s.y,l.x,l.y),s=l;return o;case"Q":for(o=0,s=f.getPointOnQuadraticBezier(0,e,n,r[0],r[1],r[2],r[3]),c=.01;c<=1;c+=.01)l=f.getPointOnQuadraticBezier(c,e,n,r[0],r[1],r[2],r[3]),o+=f.getLineLength(s.x,s.y,l.x,l.y),s=l;return o;case"A":o=0;var h=r[4],u=r[5],i=r[4]+u,d=Math.PI/180;if(Math.abs(h-i)<d&&(d=Math.abs(h-i)),s=f.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],h,0),u<0)for(c=h-d;c>i;c-=d)l=f.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],c,0),o+=f.getLineLength(s.x,s.y,l.x,l.y),s=l;else for(c=h+d;c<i;c+=d)l=f.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],c,0),o+=f.getLineLength(s.x,s.y,l.x,l.y),s=l;return l=f.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],i,0),o+=f.getLineLength(s.x,s.y,l.x,l.y),o}return 0}static convertEndpointToCenterParameterization(e,n,t,r,o,s,l,c,f){var h=f*(Math.PI/180),u=Math.cos(h)*(e-t)/2+Math.sin(h)*(n-r)/2,i=-1*Math.sin(h)*(e-t)/2+Math.cos(h)*(n-r)/2,d=u*u/(l*l)+i*i/(c*c);d>1&&(l*=Math.sqrt(d),c*=Math.sqrt(d));var p=Math.sqrt((l*l*(c*c)-l*l*(i*i)-c*c*(u*u))/(l*l*(i*i)+c*c*(u*u)));o===s&&(p*=-1),isNaN(p)&&(p=0);var _=p*l*i/c,m=p*-c*u/l,g=(e+t)/2+Math.cos(h)*_-Math.sin(h)*m,b=(n+r)/2+Math.sin(h)*_+Math.cos(h)*m,v=function(E){return Math.sqrt(E[0]*E[0]+E[1]*E[1])},T=function(E,A){return(E[0]*A[0]+E[1]*A[1])/(v(E)*v(A))},y=function(E,A){return(E[0]*A[1]<E[1]*A[0]?-1:1)*Math.acos(T(E,A))},w=y([1,0],[(u-_)/l,(i-m)/c]),S=[(u-_)/l,(i-m)/c],O=[(-1*u-_)/l,(-1*i-m)/c],P=y(S,O);return T(S,O)<=-1&&(P=Math.PI),T(S,O)>=1&&(P=0),s===0&&P>0&&(P=P-2*Math.PI),s===1&&P<0&&(P=P+2*Math.PI),[g,b,l,c,w,P,h,s]}}Path.prototype.className="Path";Path.prototype._attrsAffectingSize=["data"];_registerNode(Path);Factory.addGetterSetter(Path,"data");class Arrow extends Line$1{_sceneFunc(e){super._sceneFunc(e);var n=Math.PI*2,t=this.points(),r=t,o=this.tension()!==0&&t.length>4;o&&(r=this.getTensionPoints());var s=this.pointerLength(),l=t.length,c,f;if(o){const i=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],t[l-2],t[l-1]],d=Path.calcLength(r[r.length-4],r[r.length-3],"C",i),p=Path.getPointOnQuadraticBezier(Math.min(1,1-s/d),i[0],i[1],i[2],i[3],i[4],i[5]);c=t[l-2]-p.x,f=t[l-1]-p.y}else c=t[l-2]-t[l-4],f=t[l-1]-t[l-3];var h=(Math.atan2(f,c)+n)%n,u=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(t[l-2],t[l-1]),e.rotate(h),e.moveTo(0,0),e.lineTo(-s,u/2),e.lineTo(-s,-u/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(t[0],t[1]),o?(c=(r[0]+r[2])/2-t[0],f=(r[1]+r[3])/2-t[1]):(c=t[2]-t[0],f=t[3]-t[1]),e.rotate((Math.atan2(-f,-c)+n)%n),e.moveTo(0,0),e.lineTo(-s,u/2),e.lineTo(-s,-u/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){var n=this.dashEnabled();n&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),n&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),n=this.pointerWidth()/2;return{x:e.x-n,y:e.y-n,width:e.width+n*2,height:e.height+n*2}}}Arrow.prototype.className="Arrow";_registerNode(Arrow);Factory.addGetterSetter(Arrow,"pointerLength",10,getNumberValidator());Factory.addGetterSetter(Arrow,"pointerWidth",10,getNumberValidator());Factory.addGetterSetter(Arrow,"pointerAtBeginning",!1);Factory.addGetterSetter(Arrow,"pointerAtEnding",!0);let Circle$1=class extends Shape$1{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}};Circle$1.prototype._centroid=!0;Circle$1.prototype.className="Circle";Circle$1.prototype._attrsAffectingSize=["radius"];_registerNode(Circle$1);Factory.addGetterSetter(Circle$1,"radius",0,getNumberValidator());class Ellipse extends Shape$1{_sceneFunc(e){var n=this.radiusX(),t=this.radiusY();e.beginPath(),e.save(),n!==t&&e.scale(1,t/n),e.arc(0,0,n,0,Math.PI*2,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radiusX()*2}getHeight(){return this.radiusY()*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}}Ellipse.prototype.className="Ellipse";Ellipse.prototype._centroid=!0;Ellipse.prototype._attrsAffectingSize=["radiusX","radiusY"];_registerNode(Ellipse);Factory.addComponentsGetterSetter(Ellipse,"radius",["x","y"]);Factory.addGetterSetter(Ellipse,"radiusX",0,getNumberValidator());Factory.addGetterSetter(Ellipse,"radiusY",0,getNumberValidator());let Image$2=class Gt extends Shape$1{constructor(e){super(e),this.on("imageChange.konva",()=>{this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const e=this.image();e&&e.complete||e&&e.readyState===4||e&&e.addEventListener&&e.addEventListener("load",()=>{this._requestDraw()})}_useBufferCanvas(){return super._useBufferCanvas(!0)}_sceneFunc(e){const n=this.getWidth(),t=this.getHeight(),r=this.cornerRadius(),o=this.attrs.image;let s;if(o){const l=this.attrs.cropWidth,c=this.attrs.cropHeight;l&&c?s=[o,this.cropX(),this.cropY(),l,c,0,0,n,t]:s=[o,0,0,n,t]}(this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?Util.drawRoundedRectPath(e,n,t,r):e.rect(0,0,n,t),e.closePath(),e.fillStrokeShape(this)),o&&(r&&e.clip(),e.drawImage.apply(e,s))}_hitFunc(e){var n=this.width(),t=this.height(),r=this.cornerRadius();e.beginPath(),r?Util.drawRoundedRectPath(e,n,t,r):e.rect(0,0,n,t),e.closePath(),e.fillStrokeShape(this)}getWidth(){var e,n;return(e=this.attrs.width)!==null&&e!==void 0?e:(n=this.image())===null||n===void 0?void 0:n.width}getHeight(){var e,n;return(e=this.attrs.height)!==null&&e!==void 0?e:(n=this.image())===null||n===void 0?void 0:n.height}static fromURL(e,n,t=null){var r=Util.createImageElement();r.onload=function(){var o=new Gt({image:r});n(o)},r.onerror=t,r.crossOrigin="Anonymous",r.src=e}};Image$2.prototype.className="Image";_registerNode(Image$2);Factory.addGetterSetter(Image$2,"cornerRadius",0,getNumberOrArrayOfNumbersValidator(4));Factory.addGetterSetter(Image$2,"image");Factory.addComponentsGetterSetter(Image$2,"crop",["x","y","width","height"]);Factory.addGetterSetter(Image$2,"cropX",0,getNumberValidator());Factory.addGetterSetter(Image$2,"cropY",0,getNumberValidator());Factory.addGetterSetter(Image$2,"cropWidth",0,getNumberValidator());Factory.addGetterSetter(Image$2,"cropHeight",0,getNumberValidator());var ATTR_CHANGE_LIST$2=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],CHANGE_KONVA$1="Change.konva",NONE$1="none",UP="up",RIGHT$1="right",DOWN="down",LEFT$1="left",attrChangeListLen$1=ATTR_CHANGE_LIST$2.length;let Label$1=class extends Group$1{constructor(e){super(e),this.on("add.konva",function(n){this._addListeners(n.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){var n=this,t,r=function(){n._sync()};for(t=0;t<attrChangeListLen$1;t++)e.on(ATTR_CHANGE_LIST$2[t]+CHANGE_KONVA$1,r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var e=this.getText(),n=this.getTag(),t,r,o,s,l,c,f;if(e&&n){switch(t=e.width(),r=e.height(),o=n.pointerDirection(),s=n.pointerWidth(),f=n.pointerHeight(),l=0,c=0,o){case UP:l=t/2,c=-1*f;break;case RIGHT$1:l=t+s,c=r/2;break;case DOWN:l=t/2,c=r+f;break;case LEFT$1:l=-1*s,c=r/2;break}n.setAttrs({x:-1*l,y:-1*c,width:t,height:r}),e.setAttrs({x:-1*l,y:-1*c})}}};Label$1.prototype.className="Label";_registerNode(Label$1);let Tag$1=class extends Shape$1{_sceneFunc(e){var n=this.width(),t=this.height(),r=this.pointerDirection(),o=this.pointerWidth(),s=this.pointerHeight(),l=this.cornerRadius();let c=0,f=0,h=0,u=0;typeof l=="number"?c=f=h=u=Math.min(l,n/2,t/2):(c=Math.min(l[0]||0,n/2,t/2),f=Math.min(l[1]||0,n/2,t/2),u=Math.min(l[2]||0,n/2,t/2),h=Math.min(l[3]||0,n/2,t/2)),e.beginPath(),e.moveTo(c,0),r===UP&&(e.lineTo((n-o)/2,0),e.lineTo(n/2,-1*s),e.lineTo((n+o)/2,0)),e.lineTo(n-f,0),e.arc(n-f,f,f,Math.PI*3/2,0,!1),r===RIGHT$1&&(e.lineTo(n,(t-s)/2),e.lineTo(n+o,t/2),e.lineTo(n,(t+s)/2)),e.lineTo(n,t-u),e.arc(n-u,t-u,u,0,Math.PI/2,!1),r===DOWN&&(e.lineTo((n+o)/2,t),e.lineTo(n/2,t+s),e.lineTo((n-o)/2,t)),e.lineTo(h,t),e.arc(h,t-h,h,Math.PI/2,Math.PI,!1),r===LEFT$1&&(e.lineTo(0,(t+s)/2),e.lineTo(-1*o,t/2),e.lineTo(0,(t-s)/2)),e.lineTo(0,c),e.arc(c,c,c,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){var e=0,n=0,t=this.pointerWidth(),r=this.pointerHeight(),o=this.pointerDirection(),s=this.width(),l=this.height();return o===UP?(n-=r,l+=r):o===DOWN?l+=r:o===LEFT$1?(e-=t*1.5,s+=t):o===RIGHT$1&&(s+=t*1.5),{x:e,y:n,width:s,height:l}}};Tag$1.prototype.className="Tag";_registerNode(Tag$1);Factory.addGetterSetter(Tag$1,"pointerDirection",NONE$1);Factory.addGetterSetter(Tag$1,"pointerWidth",0,getNumberValidator());Factory.addGetterSetter(Tag$1,"pointerHeight",0,getNumberValidator());Factory.addGetterSetter(Tag$1,"cornerRadius",0,getNumberOrArrayOfNumbersValidator(4));let Rect$1=class extends Shape$1{_sceneFunc(e){var n=this.cornerRadius(),t=this.width(),r=this.height();e.beginPath(),n?Util.drawRoundedRectPath(e,t,r,n):e.rect(0,0,t,r),e.closePath(),e.fillStrokeShape(this)}};Rect$1.prototype.className="Rect";_registerNode(Rect$1);Factory.addGetterSetter(Rect$1,"cornerRadius",0,getNumberOrArrayOfNumbersValidator(4));class RegularPolygon extends Shape$1{_sceneFunc(e){const n=this._getPoints();e.beginPath(),e.moveTo(n[0].x,n[0].y);for(var t=1;t<n.length;t++)e.lineTo(n[t].x,n[t].y);e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,n=this.attrs.radius||0,t=[];for(var r=0;r<e;r++)t.push({x:n*Math.sin(r*2*Math.PI/e),y:-1*n*Math.cos(r*2*Math.PI/e)});return t}getSelfRect(){const e=this._getPoints();var n=e[0].x,t=e[0].y,r=e[0].x,o=e[0].y;return e.forEach(s=>{n=Math.min(n,s.x),t=Math.max(t,s.x),r=Math.min(r,s.y),o=Math.max(o,s.y)}),{x:n,y:r,width:t-n,height:o-r}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}RegularPolygon.prototype.className="RegularPolygon";RegularPolygon.prototype._centroid=!0;RegularPolygon.prototype._attrsAffectingSize=["radius"];_registerNode(RegularPolygon);Factory.addGetterSetter(RegularPolygon,"radius",0,getNumberValidator());Factory.addGetterSetter(RegularPolygon,"sides",0,getNumberValidator());var PIx2=Math.PI*2;class Ring extends Shape$1{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,PIx2,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),PIx2,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}Ring.prototype.className="Ring";Ring.prototype._centroid=!0;Ring.prototype._attrsAffectingSize=["innerRadius","outerRadius"];_registerNode(Ring);Factory.addGetterSetter(Ring,"innerRadius",0,getNumberValidator());Factory.addGetterSetter(Ring,"outerRadius",0,getNumberValidator());class Sprite extends Shape$1{constructor(e){super(e),this._updated=!0,this.anim=new Animation(()=>{var n=this._updated;return this._updated=!1,n}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(e){var n=this.animation(),t=this.frameIndex(),r=t*4,o=this.animations()[n],s=this.frameOffsets(),l=o[r+0],c=o[r+1],f=o[r+2],h=o[r+3],u=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,f,h),e.closePath(),e.fillStrokeShape(this)),u)if(s){var i=s[n],d=t*2;e.drawImage(u,l,c,f,h,i[d+0],i[d+1],f,h)}else e.drawImage(u,l,c,f,h,0,0,f,h)}_hitFunc(e){var n=this.animation(),t=this.frameIndex(),r=t*4,o=this.animations()[n],s=this.frameOffsets(),l=o[r+2],c=o[r+3];if(e.beginPath(),s){var f=s[n],h=t*2;e.rect(f[h+0],f[h+1],l,c)}else e.rect(0,0,l,c);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){var e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(!this.isRunning()){var e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){var e=this.frameIndex(),n=this.animation(),t=this.animations(),r=t[n],o=r.length/4;e<o-1?this.frameIndex(e+1):this.frameIndex(0)}}Sprite.prototype.className="Sprite";_registerNode(Sprite);Factory.addGetterSetter(Sprite,"animation");Factory.addGetterSetter(Sprite,"animations");Factory.addGetterSetter(Sprite,"frameOffsets");Factory.addGetterSetter(Sprite,"image");Factory.addGetterSetter(Sprite,"frameIndex",0,getNumberValidator());Factory.addGetterSetter(Sprite,"frameRate",17,getNumberValidator());Factory.backCompat(Sprite,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class Star extends Shape$1{_sceneFunc(e){var n=this.innerRadius(),t=this.outerRadius(),r=this.numPoints();e.beginPath(),e.moveTo(0,0-t);for(var o=1;o<r*2;o++){var s=o%2===0?t:n,l=s*Math.sin(o*Math.PI/r),c=-1*s*Math.cos(o*Math.PI/r);e.lineTo(l,c)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}Star.prototype.className="Star";Star.prototype._centroid=!0;Star.prototype._attrsAffectingSize=["innerRadius","outerRadius"];_registerNode(Star);Factory.addGetterSetter(Star,"numPoints",5,getNumberValidator());Factory.addGetterSetter(Star,"innerRadius",0,getNumberValidator());Factory.addGetterSetter(Star,"outerRadius",0,getNumberValidator());function stringToArray(a){return Array.from(a)}var AUTO="auto",CENTER="center",JUSTIFY="justify",CHANGE_KONVA="Change.konva",CONTEXT_2D="2d",DASH="-",LEFT="left",TEXT="text",TEXT_UPPER="Text",TOP="top",BOTTOM="bottom",MIDDLE="middle",NORMAL$1="normal",PX_SPACE="px ",SPACE=" ",RIGHT="right",WORD="word",CHAR="char",NONE="none",ELLIPSIS="…",ATTR_CHANGE_LIST$1=["fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],attrChangeListLen=ATTR_CHANGE_LIST$1.length;function normalizeFontFamily(a){return a.split(",").map(e=>{e=e.trim();const n=e.indexOf(" ")>=0,t=e.indexOf('"')>=0||e.indexOf("'")>=0;return n&&!t&&(e=`"${e}"`),e}).join(", ")}var dummyContext;function getDummyContext(){return dummyContext||(dummyContext=Util.createCanvasElement().getContext(CONTEXT_2D),dummyContext)}function _fillFunc$1(a){a.fillText(this._partialText,this._partialTextX,this._partialTextY)}function _strokeFunc$1(a){a.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function checkDefaultFill(a){return a=a||{},!a.fillLinearGradientColorStops&&!a.fillRadialGradientColorStops&&!a.fillPatternImage&&(a.fill=a.fill||"black"),a}let Text$1=class extends Shape$1{constructor(e){super(checkDefaultFill(e)),this._partialTextX=0,this._partialTextY=0;for(var n=0;n<attrChangeListLen;n++)this.on(ATTR_CHANGE_LIST$1[n]+CHANGE_KONVA,this._setTextData);this._setTextData()}_sceneFunc(e){var n=this.textArr,t=n.length;if(this.text()){var r=this.padding(),o=this.fontSize(),s=this.lineHeight()*o,l=this.verticalAlign(),c=0,f=this.align(),h=this.getWidth(),u=this.letterSpacing(),i=this.fill(),d=this.textDecoration(),p=d.indexOf("underline")!==-1,_=d.indexOf("line-through")!==-1,m,g=0,g=s/2,b=0,v=0;for(e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",MIDDLE),e.setAttr("textAlign",LEFT),l===MIDDLE?c=(this.getHeight()-t*s-r*2)/2:l===BOTTOM&&(c=this.getHeight()-t*s-r*2),e.translate(r,c+r),m=0;m<t;m++){var b=0,v=0,T=n[m],y=T.text,w=T.width,S=T.lastInParagraph,O,P,E;if(e.save(),f===RIGHT?b+=h-w-r*2:f===CENTER&&(b+=(h-w-r*2)/2),p){e.save(),e.beginPath(),e.moveTo(b,g+v+Math.round(o/2)),O=y.split(" ").length-1,P=O===0,E=f===JUSTIFY&&!S?h-r*2:w,e.lineTo(b+Math.round(E),g+v+Math.round(o/2)),e.lineWidth=o/15;const C=this._getLinearGradient();e.strokeStyle=C||i,e.stroke(),e.restore()}if(_){e.save(),e.beginPath(),e.moveTo(b,g+v),O=y.split(" ").length-1,P=O===0,E=f===JUSTIFY&&S&&!P?h-r*2:w,e.lineTo(b+Math.round(E),g+v),e.lineWidth=o/15;const C=this._getLinearGradient();e.strokeStyle=C||i,e.stroke(),e.restore()}if(u!==0||f===JUSTIFY){O=y.split(" ").length-1;for(var A=stringToArray(y),$=0;$<A.length;$++){var k=A[$];k===" "&&!S&&f===JUSTIFY&&(b+=(h-r*2-w)/O),this._partialTextX=b,this._partialTextY=g+v,this._partialText=k,e.fillStrokeShape(this),b+=this.measureSize(k).width+u}}else this._partialTextX=b,this._partialTextY=g+v,this._partialText=y,e.fillStrokeShape(this);e.restore(),t>1&&(g+=s)}}}_hitFunc(e){var n=this.getWidth(),t=this.getHeight();e.beginPath(),e.rect(0,0,n,t),e.closePath(),e.fillStrokeShape(this)}setText(e){var n=Util._isString(e)?e:e==null?"":e+"";return this._setAttr(TEXT,n),this}getWidth(){var e=this.attrs.width===AUTO||this.attrs.width===void 0;return e?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){var e=this.attrs.height===AUTO||this.attrs.height===void 0;return e?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(e){var n=getDummyContext(),t=this.fontSize(),r;return n.save(),n.font=this._getContextFont(),r=n.measureText(e),n.restore(),{width:r.width,height:t}}_getContextFont(){return this.fontStyle()+SPACE+this.fontVariant()+SPACE+(this.fontSize()+PX_SPACE)+normalizeFontFamily(this.fontFamily())}_addTextLine(e){this.align()===JUSTIFY&&(e=e.trim());var t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){var n=this.letterSpacing(),t=e.length;return getDummyContext().measureText(e).width+(t?n*(t-1):0)}_setTextData(){var e=this.text().split(`
`),n=+this.fontSize(),t=0,r=this.lineHeight()*n,o=this.attrs.width,s=this.attrs.height,l=o!==AUTO&&o!==void 0,c=s!==AUTO&&s!==void 0,f=this.padding(),h=o-f*2,u=s-f*2,i=0,d=this.wrap(),p=d!==NONE,_=d!==CHAR&&p,m=this.ellipsis();this.textArr=[],getDummyContext().font=this._getContextFont();for(var g=m?this._getTextWidth(ELLIPSIS):0,b=0,v=e.length;b<v;++b){var T=e[b],y=this._getTextWidth(T);if(l&&y>h)for(;T.length>0;){for(var w=0,S=T.length,O="",P=0;w<S;){var E=w+S>>>1,A=T.slice(0,E+1),$=this._getTextWidth(A)+g;$<=h?(w=E+1,O=A,P=$):S=E}if(O){if(_){var k,D=T[O.length],I=D===SPACE||D===DASH;I&&P<=h?k=O.length:k=Math.max(O.lastIndexOf(SPACE),O.lastIndexOf(DASH))+1,k>0&&(w=k,O=O.slice(0,w),P=this._getTextWidth(O))}O=O.trimRight(),this._addTextLine(O),t=Math.max(t,P),i+=r;var C=this._shouldHandleEllipsis(i);if(C){this._tryToAddEllipsisToLastLine();break}if(T=T.slice(w),T=T.trimLeft(),T.length>0&&(y=this._getTextWidth(T),y<=h)){this._addTextLine(T),i+=r,t=Math.max(t,y);break}}else break}else this._addTextLine(T),i+=r,t=Math.max(t,y),this._shouldHandleEllipsis(i)&&b<v-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),c&&i+r>u)break}this.textHeight=n,this.textWidth=t}_shouldHandleEllipsis(e){var n=+this.fontSize(),t=this.lineHeight()*n,r=this.attrs.height,o=r!==AUTO&&r!==void 0,s=this.padding(),l=r-s*2,c=this.wrap(),f=c!==NONE;return!f||o&&e+t>l}_tryToAddEllipsisToLastLine(){var e=this.attrs.width,n=e!==AUTO&&e!==void 0,t=this.padding(),r=e-t*2,o=this.ellipsis(),s=this.textArr[this.textArr.length-1];if(!(!s||!o)){if(n){var l=this._getTextWidth(s.text+ELLIPSIS)<r;l||(s.text=s.text.slice(0,s.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(s.text+ELLIPSIS)}}getStrokeScaleEnabled(){return!0}};Text$1.prototype._fillFunc=_fillFunc$1;Text$1.prototype._strokeFunc=_strokeFunc$1;Text$1.prototype.className=TEXT_UPPER;Text$1.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"];_registerNode(Text$1);Factory.overWriteSetter(Text$1,"width",getNumberOrAutoValidator());Factory.overWriteSetter(Text$1,"height",getNumberOrAutoValidator());Factory.addGetterSetter(Text$1,"fontFamily","Arial");Factory.addGetterSetter(Text$1,"fontSize",12,getNumberValidator());Factory.addGetterSetter(Text$1,"fontStyle",NORMAL$1);Factory.addGetterSetter(Text$1,"fontVariant",NORMAL$1);Factory.addGetterSetter(Text$1,"padding",0,getNumberValidator());Factory.addGetterSetter(Text$1,"align",LEFT);Factory.addGetterSetter(Text$1,"verticalAlign",TOP);Factory.addGetterSetter(Text$1,"lineHeight",1,getNumberValidator());Factory.addGetterSetter(Text$1,"wrap",WORD);Factory.addGetterSetter(Text$1,"ellipsis",!1,getBooleanValidator());Factory.addGetterSetter(Text$1,"letterSpacing",0,getNumberValidator());Factory.addGetterSetter(Text$1,"text","",getStringValidator());Factory.addGetterSetter(Text$1,"textDecoration","");var EMPTY_STRING="",NORMAL="normal";function _fillFunc(a){a.fillText(this.partialText,0,0)}function _strokeFunc(a){a.strokeText(this.partialText,0,0)}class TextPath extends Shape$1{constructor(e){super(e),this.dummyCanvas=Util.createCanvasElement(),this.dataArray=[],this.dataArray=Path.parsePathData(this.attrs.data),this.on("dataChange.konva",function(){this.dataArray=Path.parsePathData(this.attrs.data),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();var n=this.textDecoration(),t=this.fill(),r=this.fontSize(),o=this.glyphInfo;n==="underline"&&e.beginPath();for(var s=0;s<o.length;s++){e.save();var l=o[s].p0;e.translate(l.x,l.y),e.rotate(o[s].rotation),this.partialText=o[s].text,e.fillStrokeShape(this),n==="underline"&&(s===0&&e.moveTo(0,r/2+1),e.lineTo(r,r/2+1)),e.restore()}n==="underline"&&(e.strokeStyle=t,e.lineWidth=r/20,e.stroke()),e.restore()}_hitFunc(e){e.beginPath();var n=this.glyphInfo;if(n.length>=1){var t=n[0].p0;e.moveTo(t.x,t.y)}for(var r=0;r<n.length;r++){var o=n[r].p1;e.lineTo(o.x,o.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return Text$1.prototype.setText.call(this,e)}_getContextFont(){return Text$1.prototype._getContextFont.call(this)}_getTextSize(e){var n=this.dummyCanvas,t=n.getContext("2d");t.save(),t.font=this._getContextFont();var r=t.measureText(e);return t.restore(),{width:r.width,height:parseInt(this.attrs.fontSize,10)}}_setTextData(){var e=this,n=this._getTextSize(this.attrs.text),t=this.letterSpacing(),r=this.align(),o=this.kerningFunc();this.textWidth=n.width,this.textHeight=n.height;var s=Math.max(this.textWidth+((this.attrs.text||"").length-1)*t,0);this.glyphInfo=[];for(var l=0,c=0;c<e.dataArray.length;c++)e.dataArray[c].pathLength>0&&(l+=e.dataArray[c].pathLength);var f=0;r==="center"&&(f=Math.max(0,l/2-s/2)),r==="right"&&(f=Math.max(0,l-s));for(var h=stringToArray(this.text()),u=this.text().split(" ").length-1,i,d,p,_=-1,m=0,g=function(){m=0;for(var $=e.dataArray,k=_+1;k<$.length;k++){if($[k].pathLength>0)return _=k,$[k];$[k].command==="M"&&(i={x:$[k].points[0],y:$[k].points[1]})}return{}},b=function($){var k=e._getTextSize($).width+t;$===" "&&r==="justify"&&(k+=(l-s)/u);var D=0,I=0;for(d=void 0;Math.abs(k-D)/k>.01&&I<20;){I++;for(var C=D;p===void 0;)p=g(),p&&C+p.pathLength<k&&(C+=p.pathLength,p=void 0);if(Object.keys(p).length===0||i===void 0)return;var L=!1;switch(p.command){case"L":Path.getLineLength(i.x,i.y,p.points[0],p.points[1])>k?d=Path.getPointOnLine(k,i.x,i.y,p.points[0],p.points[1],i.x,i.y):p=void 0;break;case"A":var K=p.points[4],G=p.points[5],J=p.points[4]+G;m===0?m=K+1e-8:k>D?m+=Math.PI/180*G/Math.abs(G):m-=Math.PI/360*G/Math.abs(G),(G<0&&m<J||G>=0&&m>J)&&(m=J,L=!0),d=Path.getPointOnEllipticalArc(p.points[0],p.points[1],p.points[2],p.points[3],m,p.points[6]);break;case"C":m===0?k>p.pathLength?m=1e-8:m=k/p.pathLength:k>D?m+=(k-D)/p.pathLength/2:m=Math.max(m-(D-k)/p.pathLength/2,0),m>1&&(m=1,L=!0),d=Path.getPointOnCubicBezier(m,p.start.x,p.start.y,p.points[0],p.points[1],p.points[2],p.points[3],p.points[4],p.points[5]);break;case"Q":m===0?m=k/p.pathLength:k>D?m+=(k-D)/p.pathLength:m-=(D-k)/p.pathLength,m>1&&(m=1,L=!0),d=Path.getPointOnQuadraticBezier(m,p.start.x,p.start.y,p.points[0],p.points[1],p.points[2],p.points[3]);break}d!==void 0&&(D=Path.getLineLength(i.x,i.y,d.x,d.y)),L&&(L=!1,p=void 0)}},v="C",T=e._getTextSize(v).width+t,y=f/T-1,w=0;w<y&&(b(v),!(i===void 0||d===void 0));w++)i=d;for(var S=0;S<h.length&&(b(h[S]),!(i===void 0||d===void 0));S++){var O=Path.getLineLength(i.x,i.y,d.x,d.y),P=0;if(o)try{P=o(h[S-1],h[S])*this.fontSize()}catch{P=0}i.x+=P,d.x+=P,this.textWidth+=P;var E=Path.getPointOnLine(P+O/2,i.x,i.y,d.x,d.y),A=Math.atan2(d.y-i.y,d.x-i.x);this.glyphInfo.push({transposeX:E.x,transposeY:E.y,text:h[S],rotation:A,p0:i,p1:d}),i=d}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};var e=[];this.glyphInfo.forEach(function(h){e.push(h.p0.x),e.push(h.p0.y),e.push(h.p1.x),e.push(h.p1.y)});for(var n=e[0]||0,t=e[0]||0,r=e[1]||0,o=e[1]||0,s,l,c=0;c<e.length/2;c++)s=e[c*2],l=e[c*2+1],n=Math.min(n,s),t=Math.max(t,s),r=Math.min(r,l),o=Math.max(o,l);var f=this.fontSize();return{x:n-f/2,y:r-f/2,width:t-n+f,height:o-r+f}}destroy(){return Util.releaseCanvas(this.dummyCanvas),super.destroy()}}TextPath.prototype._fillFunc=_fillFunc;TextPath.prototype._strokeFunc=_strokeFunc;TextPath.prototype._fillFuncHit=_fillFunc;TextPath.prototype._strokeFuncHit=_strokeFunc;TextPath.prototype.className="TextPath";TextPath.prototype._attrsAffectingSize=["text","fontSize","data"];_registerNode(TextPath);Factory.addGetterSetter(TextPath,"data");Factory.addGetterSetter(TextPath,"fontFamily","Arial");Factory.addGetterSetter(TextPath,"fontSize",12,getNumberValidator());Factory.addGetterSetter(TextPath,"fontStyle",NORMAL);Factory.addGetterSetter(TextPath,"align","left");Factory.addGetterSetter(TextPath,"letterSpacing",0,getNumberValidator());Factory.addGetterSetter(TextPath,"textBaseline","middle");Factory.addGetterSetter(TextPath,"fontVariant",NORMAL);Factory.addGetterSetter(TextPath,"text",EMPTY_STRING);Factory.addGetterSetter(TextPath,"textDecoration",null);Factory.addGetterSetter(TextPath,"kerningFunc",null);var EVENTS_NAME="tr-konva",ATTR_CHANGE_LIST=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange"].map(a=>a+`.${EVENTS_NAME}`).join(" "),NODES_RECT="nodesRect",TRANSFORM_CHANGE_STR=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],ANGLES={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135};const TOUCH_DEVICE="ontouchstart"in Konva$2._global;function getCursor(a,e){if(a==="rotater")return"crosshair";e+=Util.degToRad(ANGLES[a]||0);var n=(Util.radToDeg(e)%360+360)%360;return Util._inRange(n,315+22.5,360)||Util._inRange(n,0,22.5)?"ns-resize":Util._inRange(n,45-22.5,45+22.5)?"nesw-resize":Util._inRange(n,90-22.5,90+22.5)?"ew-resize":Util._inRange(n,135-22.5,135+22.5)?"nwse-resize":Util._inRange(n,180-22.5,180+22.5)?"ns-resize":Util._inRange(n,225-22.5,225+22.5)?"nesw-resize":Util._inRange(n,270-22.5,270+22.5)?"ew-resize":Util._inRange(n,315-22.5,315+22.5)?"nwse-resize":(Util.error("Transformer has unknown angle for cursor detection: "+n),"pointer")}var ANCHORS_NAMES=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],MAX_SAFE_INTEGER=1e8;function getCenter(a){return{x:a.x+a.width/2*Math.cos(a.rotation)+a.height/2*Math.sin(-a.rotation),y:a.y+a.height/2*Math.cos(a.rotation)+a.width/2*Math.sin(a.rotation)}}function rotateAroundPoint(a,e,n){const t=n.x+(a.x-n.x)*Math.cos(e)-(a.y-n.y)*Math.sin(e),r=n.y+(a.x-n.x)*Math.sin(e)+(a.y-n.y)*Math.cos(e);return Object.assign(Object.assign({},a),{rotation:a.rotation+e,x:t,y:r})}function rotateAroundCenter(a,e){const n=getCenter(a);return rotateAroundPoint(a,e,n)}function getSnap(a,e,n){let t=e;for(let r=0;r<a.length;r++){const o=Konva$2.getAngle(a[r]),s=Math.abs(o-e)%(Math.PI*2);Math.min(s,Math.PI*2-s)<n&&(t=o)}return t}class Transformer extends Group$1{constructor(e){super(e),this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(ATTR_CHANGE_LIST,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return EVENTS_NAME+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const n=e.filter(r=>r.isAncestorOf(this)?(Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1):!0);this._nodes=e=n,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(r=>{const o=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()},s=r._attrsAffectingSize.map(l=>l+"Change."+this._getEventNamespace()).join(" ");r.on(s,o),r.on(TRANSFORM_CHANGE_STR.map(l=>l+`.${this._getEventNamespace()}`).join(" "),o),r.on(`absoluteTransformChange.${this._getEventNamespace()}`,o),this._proxyDrag(r)}),this._resetTransformCache();var t=!!this.findOne(".top-left");return t&&this.update(),this}_proxyDrag(e){let n;e.on(`dragstart.${this._getEventNamespace()}`,t=>{n=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back")&&this.startDrag(t,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,t=>{if(!n)return;const r=e.getAbsolutePosition(),o=r.x-n.x,s=r.y-n.y;this.nodes().forEach(l=>{if(l===e||l.isDragging())return;const c=l.getAbsolutePosition();l.setAbsolutePosition({x:c.x+o,y:c.y+s}),l.startDrag(t)}),n=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(e=>{e.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(NODES_RECT),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(NODES_RECT,this.__getNodeRect)}__getNodeShape(e,n=this.rotation(),t){var r=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),o=e.getAbsoluteScale(t),s=e.getAbsolutePosition(t),l=r.x*o.x-e.offsetX()*o.x,c=r.y*o.y-e.offsetY()*o.y;const f=(Konva$2.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2),h={x:s.x+l*Math.cos(f)+c*Math.sin(-f),y:s.y+c*Math.cos(f)+l*Math.sin(f),width:r.width*o.x,height:r.height*o.y,rotation:f};return rotateAroundPoint(h,-Konva$2.getAngle(n),{x:0,y:0})}__getNodeRect(){var e=this.getNode();if(!e)return{x:-MAX_SAFE_INTEGER,y:-MAX_SAFE_INTEGER,width:0,height:0,rotation:0};const n=[];this.nodes().map(f=>{const h=f.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()});var u=[{x:h.x,y:h.y},{x:h.x+h.width,y:h.y},{x:h.x+h.width,y:h.y+h.height},{x:h.x,y:h.y+h.height}],i=f.getAbsoluteTransform();u.forEach(function(d){var p=i.point(d);n.push(p)})});const t=new Transform;t.rotate(-Konva$2.getAngle(this.rotation()));var r,o,s,l;n.forEach(function(f){var h=t.point(f);r===void 0&&(r=s=h.x,o=l=h.y),r=Math.min(r,h.x),o=Math.min(o,h.y),s=Math.max(s,h.x),l=Math.max(l,h.y)}),t.invert();const c=t.point({x:r,y:o});return{x:c.x,y:c.y,width:s-r,height:l-o,rotation:Konva$2.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),ANCHORS_NAMES.forEach((function(e){this._createAnchor(e)}).bind(this)),this._createAnchor("rotater")}_createAnchor(e){var n=new Rect$1({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:TOUCH_DEVICE?10:"auto"}),t=this;n.on("mousedown touchstart",function(r){t._handleMouseDown(r)}),n.on("dragstart",r=>{n.stopDrag(),r.cancelBubble=!0}),n.on("dragend",r=>{r.cancelBubble=!0}),n.on("mouseenter",()=>{var r=Konva$2.getAngle(this.rotation()),o=getCursor(e,r);n.getStage().content&&(n.getStage().content.style.cursor=o),this._cursorChange=!0}),n.on("mouseout",()=>{n.getStage().content&&(n.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(n)}_createBack(){var e=new Shape$1({name:"back",width:0,height:0,draggable:!0,sceneFunc(n){var t=this.getParent(),r=t.padding();n.beginPath(),n.rect(-r,-r,this.width()+r*2,this.height()+r*2),n.moveTo(this.width()/2,-r),t.rotateEnabled()&&n.lineTo(this.width()/2,-t.rotateAnchorOffset()*Util._sign(this.height())-r),n.fillStrokeShape(this)},hitFunc:(n,t)=>{if(this.shouldOverdrawWholeArea()){var r=this.padding();n.beginPath(),n.rect(-r,-r,t.width()+r*2,t.height()+r*2),n.fillStrokeShape(t)}}});this.add(e),this._proxyDrag(e),e.on("dragstart",n=>{n.cancelBubble=!0}),e.on("dragmove",n=>{n.cancelBubble=!0}),e.on("dragend",n=>{n.cancelBubble=!0}),this.on("dragmove",n=>{this.update()})}_handleMouseDown(e){this._movingAnchorName=e.target.name().split(" ")[0];var n=this._getNodeRect(),t=n.width,r=n.height,o=Math.sqrt(Math.pow(t,2)+Math.pow(r,2));this.sin=Math.abs(r/o),this.cos=Math.abs(t/o),typeof window<"u"&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;var s=e.target.getAbsolutePosition(),l=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:l.x-s.x,y:l.y-s.y},this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach(c=>{c._fire("transformstart",{evt:e.evt,target:c})})}_handleMouseMove(e){var n,t,r,o=this.findOne("."+this._movingAnchorName),s=o.getStage();s.setPointersPositions(e);const l=s.getPointerPosition();let c={x:l.x-this._anchorDragOffset.x,y:l.y-this._anchorDragOffset.y};const f=o.getAbsolutePosition();this.anchorDragBoundFunc()&&(c=this.anchorDragBoundFunc()(f,c,e)),o.setAbsolutePosition(c);const h=o.getAbsolutePosition();if(!(f.x===h.x&&f.y===h.y)){if(this._movingAnchorName==="rotater"){var u=this._getNodeRect();n=o.x()-u.width/2,t=-o.y()+u.height/2;let $=Math.atan2(-t,n)+Math.PI/2;u.height<0&&($-=Math.PI);var i=Konva$2.getAngle(this.rotation());const k=i+$,D=Konva$2.getAngle(this.rotationSnapTolerance()),C=getSnap(this.rotationSnaps(),k,D)-u.rotation,L=rotateAroundCenter(u,C);this._fitNodesInto(L,e);return}var d=this.keepRatio()||e.shiftKey,b=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(d){var p=b?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(p.x-o.x(),2)+Math.pow(p.y-o.y(),2));var _=this.findOne(".top-left").x()>p.x?-1:1,m=this.findOne(".top-left").y()>p.y?-1:1;n=r*this.cos*_,t=r*this.sin*m,this.findOne(".top-left").x(p.x-n),this.findOne(".top-left").y(p.y-t)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(o.y());else if(this._movingAnchorName==="top-right"){if(d){var p=b?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};r=Math.sqrt(Math.pow(o.x()-p.x,2)+Math.pow(p.y-o.y(),2));var _=this.findOne(".top-right").x()<p.x?-1:1,m=this.findOne(".top-right").y()>p.y?-1:1;n=r*this.cos*_,t=r*this.sin*m,this.findOne(".top-right").x(p.x+n),this.findOne(".top-right").y(p.y-t)}var g=o.position();this.findOne(".top-left").y(g.y),this.findOne(".bottom-right").x(g.x)}else if(this._movingAnchorName==="middle-left")this.findOne(".top-left").x(o.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(o.x());else if(this._movingAnchorName==="bottom-left"){if(d){var p=b?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};r=Math.sqrt(Math.pow(p.x-o.x(),2)+Math.pow(o.y()-p.y,2));var _=p.x<o.x()?-1:1,m=o.y()<p.y?-1:1;n=r*this.cos*_,t=r*this.sin*m,o.x(p.x-n),o.y(p.y+t)}g=o.position(),this.findOne(".top-left").x(g.x),this.findOne(".bottom-right").y(g.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(o.y());else if(this._movingAnchorName==="bottom-right"){if(d){var p=b?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};r=Math.sqrt(Math.pow(o.x()-p.x,2)+Math.pow(o.y()-p.y,2));var _=this.findOne(".bottom-right").x()<p.x?-1:1,m=this.findOne(".bottom-right").y()<p.y?-1:1;n=r*this.cos*_,t=r*this.sin*m,this.findOne(".bottom-right").x(p.x+n),this.findOne(".bottom-right").y(p.y+t)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));var b=this.centeredScaling()||e.altKey;if(b){var v=this.findOne(".top-left"),T=this.findOne(".bottom-right"),y=v.x(),w=v.y(),S=this.getWidth()-T.x(),O=this.getHeight()-T.y();T.move({x:-y,y:-w}),v.move({x:S,y:O})}var P=this.findOne(".top-left").getAbsolutePosition();n=P.x,t=P.y;var E=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),A=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:n,y:t,width:E,height:A,rotation:Konva$2.getAngle(this.rotation())},e)}}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){if(this._transforming){this._transforming=!1,typeof window<"u"&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));var n=this.getNode();this._fire("transformend",{evt:e,target:n}),n&&this._nodes.forEach(t=>{t._fire("transformend",{evt:e,target:t})}),this._movingAnchorName=null}}_fitNodesInto(e,n){var t=this._getNodeRect();const r=1;if(Util._inRange(e.width,-this.padding()*2-r,r)){this.update();return}if(Util._inRange(e.height,-this.padding()*2-r,r)){this.update();return}const o=this.flipEnabled();var s=new Transform;if(s.rotate(Konva$2.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const u=s.point({x:-this.padding()*2,y:0});if(e.x+=u.x,e.y+=u.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=u.x,this._anchorDragOffset.y-=u.y,!o){this.update();return}}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const u=s.point({x:this.padding()*2,y:0});if(this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=u.x,this._anchorDragOffset.y-=u.y,e.width+=this.padding()*2,!o){this.update();return}}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const u=s.point({x:0,y:-this.padding()*2});if(e.x+=u.x,e.y+=u.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=u.x,this._anchorDragOffset.y-=u.y,e.height+=this.padding()*2,!o){this.update();return}}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const u=s.point({x:0,y:this.padding()*2});if(this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=u.x,this._anchorDragOffset.y-=u.y,e.height+=this.padding()*2,!o){this.update();return}}if(this.boundBoxFunc()){const u=this.boundBoxFunc()(t,e);u?e=u:Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const l=1e7,c=new Transform;c.translate(t.x,t.y),c.rotate(t.rotation),c.scale(t.width/l,t.height/l);const f=new Transform;f.translate(e.x,e.y),f.rotate(e.rotation),f.scale(e.width/l,e.height/l);const h=f.multiply(c.invert());this._nodes.forEach(u=>{var i;const d=u.getParent().getAbsoluteTransform(),p=u.getTransform().copy();p.translate(u.offsetX(),u.offsetY());const _=new Transform;_.multiply(d.copy().invert()).multiply(h).multiply(d).multiply(p);const m=_.decompose();u.setAttrs(m),this._fire("transform",{evt:n,target:u}),u._fire("transform",{evt:n,target:u}),(i=u.getLayer())===null||i===void 0||i.batchDraw()}),this.rotation(Util._getRotation(e.rotation)),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,n){this.findOne(e).setAttrs(n)}update(){var e,n=this._getNodeRect();this.rotation(Util._getRotation(n.rotation));var t=n.width,r=n.height,o=this.enabledAnchors(),s=this.resizeEnabled(),l=this.padding(),c=this.anchorSize();this.find("._anchor").forEach(f=>{f.setAttrs({width:c,height:c,offsetX:c/2,offsetY:c/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:c/2+l,offsetY:c/2+l,visible:s&&o.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:t/2,y:0,offsetY:c/2+l,visible:s&&o.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:t,y:0,offsetX:c/2-l,offsetY:c/2+l,visible:s&&o.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:c/2+l,visible:s&&o.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:t,y:r/2,offsetX:c/2-l,visible:s&&o.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:c/2+l,offsetY:c/2-l,visible:s&&o.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:t/2,y:r,offsetY:c/2-l,visible:s&&o.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:t,y:r,offsetX:c/2-l,offsetY:c/2-l,visible:s&&o.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:t/2,y:-this.rotateAnchorOffset()*Util._sign(r)-l,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:t,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0}),(e=this.getLayer())===null||e===void 0||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();var e=this.findOne("."+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),Group$1.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return Node.prototype.toObject.call(this)}clone(e){var n=Node.prototype.clone.call(this,e);return n}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}function validateAnchors(a){return a instanceof Array||Util.warn("enabledAnchors value should be an array"),a instanceof Array&&a.forEach(function(e){ANCHORS_NAMES.indexOf(e)===-1&&Util.warn("Unknown anchor name: "+e+". Available names are: "+ANCHORS_NAMES.join(", "))}),a||[]}Transformer.prototype.className="Transformer";_registerNode(Transformer);Factory.addGetterSetter(Transformer,"enabledAnchors",ANCHORS_NAMES,validateAnchors);Factory.addGetterSetter(Transformer,"flipEnabled",!0,getBooleanValidator());Factory.addGetterSetter(Transformer,"resizeEnabled",!0);Factory.addGetterSetter(Transformer,"anchorSize",10,getNumberValidator());Factory.addGetterSetter(Transformer,"rotateEnabled",!0);Factory.addGetterSetter(Transformer,"rotationSnaps",[]);Factory.addGetterSetter(Transformer,"rotateAnchorOffset",50,getNumberValidator());Factory.addGetterSetter(Transformer,"rotationSnapTolerance",5,getNumberValidator());Factory.addGetterSetter(Transformer,"borderEnabled",!0);Factory.addGetterSetter(Transformer,"anchorStroke","rgb(0, 161, 255)");Factory.addGetterSetter(Transformer,"anchorStrokeWidth",1,getNumberValidator());Factory.addGetterSetter(Transformer,"anchorFill","white");Factory.addGetterSetter(Transformer,"anchorCornerRadius",0,getNumberValidator());Factory.addGetterSetter(Transformer,"borderStroke","rgb(0, 161, 255)");Factory.addGetterSetter(Transformer,"borderStrokeWidth",1,getNumberValidator());Factory.addGetterSetter(Transformer,"borderDash");Factory.addGetterSetter(Transformer,"keepRatio",!0);Factory.addGetterSetter(Transformer,"centeredScaling",!1);Factory.addGetterSetter(Transformer,"ignoreStroke",!1);Factory.addGetterSetter(Transformer,"padding",0,getNumberValidator());Factory.addGetterSetter(Transformer,"node");Factory.addGetterSetter(Transformer,"nodes");Factory.addGetterSetter(Transformer,"boundBoxFunc");Factory.addGetterSetter(Transformer,"anchorDragBoundFunc");Factory.addGetterSetter(Transformer,"shouldOverdrawWholeArea",!1);Factory.addGetterSetter(Transformer,"useSingleNodeRotation",!0);Factory.backCompat(Transformer,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});class Wedge extends Shape$1{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,Konva$2.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}Wedge.prototype.className="Wedge";Wedge.prototype._centroid=!0;Wedge.prototype._attrsAffectingSize=["radius"];_registerNode(Wedge);Factory.addGetterSetter(Wedge,"radius",0,getNumberValidator());Factory.addGetterSetter(Wedge,"angle",0,getNumberValidator());Factory.addGetterSetter(Wedge,"clockwise",!1);Factory.backCompat(Wedge,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function BlurStack(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var mul_table=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],shg_table=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function filterGaussBlurRGBA(a,e){var n=a.data,t=a.width,r=a.height,o,s,l,c,f,h,u,i,d,p,_,m,g,b,v,T,y,w,S,O,P,E,A,$,k=e+e+1,D=t-1,I=r-1,C=e+1,L=C*(C+1)/2,K=new BlurStack,G=null,J=K,Y=null,te=null,ee=mul_table[e],ie=shg_table[e];for(l=1;l<k;l++)J=J.next=new BlurStack,l===C&&(G=J);for(J.next=K,u=h=0,s=0;s<r;s++){for(T=y=w=S=i=d=p=_=0,m=C*(O=n[h]),g=C*(P=n[h+1]),b=C*(E=n[h+2]),v=C*(A=n[h+3]),i+=L*O,d+=L*P,p+=L*E,_+=L*A,J=K,l=0;l<C;l++)J.r=O,J.g=P,J.b=E,J.a=A,J=J.next;for(l=1;l<C;l++)c=h+((D<l?D:l)<<2),i+=(J.r=O=n[c])*($=C-l),d+=(J.g=P=n[c+1])*$,p+=(J.b=E=n[c+2])*$,_+=(J.a=A=n[c+3])*$,T+=O,y+=P,w+=E,S+=A,J=J.next;for(Y=K,te=G,o=0;o<t;o++)n[h+3]=A=_*ee>>ie,A!==0?(A=255/A,n[h]=(i*ee>>ie)*A,n[h+1]=(d*ee>>ie)*A,n[h+2]=(p*ee>>ie)*A):n[h]=n[h+1]=n[h+2]=0,i-=m,d-=g,p-=b,_-=v,m-=Y.r,g-=Y.g,b-=Y.b,v-=Y.a,c=u+((c=o+e+1)<D?c:D)<<2,T+=Y.r=n[c],y+=Y.g=n[c+1],w+=Y.b=n[c+2],S+=Y.a=n[c+3],i+=T,d+=y,p+=w,_+=S,Y=Y.next,m+=O=te.r,g+=P=te.g,b+=E=te.b,v+=A=te.a,T-=O,y-=P,w-=E,S-=A,te=te.next,h+=4;u+=t}for(o=0;o<t;o++){for(y=w=S=T=d=p=_=i=0,h=o<<2,m=C*(O=n[h]),g=C*(P=n[h+1]),b=C*(E=n[h+2]),v=C*(A=n[h+3]),i+=L*O,d+=L*P,p+=L*E,_+=L*A,J=K,l=0;l<C;l++)J.r=O,J.g=P,J.b=E,J.a=A,J=J.next;for(f=t,l=1;l<=e;l++)h=f+o<<2,i+=(J.r=O=n[h])*($=C-l),d+=(J.g=P=n[h+1])*$,p+=(J.b=E=n[h+2])*$,_+=(J.a=A=n[h+3])*$,T+=O,y+=P,w+=E,S+=A,J=J.next,l<I&&(f+=t);for(h=o,Y=K,te=G,s=0;s<r;s++)c=h<<2,n[c+3]=A=_*ee>>ie,A>0?(A=255/A,n[c]=(i*ee>>ie)*A,n[c+1]=(d*ee>>ie)*A,n[c+2]=(p*ee>>ie)*A):n[c]=n[c+1]=n[c+2]=0,i-=m,d-=g,p-=b,_-=v,m-=Y.r,g-=Y.g,b-=Y.b,v-=Y.a,c=o+((c=s+C)<I?c:I)*t<<2,i+=T+=Y.r=n[c],d+=y+=Y.g=n[c+1],p+=w+=Y.b=n[c+2],_+=S+=Y.a=n[c+3],Y=Y.next,m+=O=te.r,g+=P=te.g,b+=E=te.b,v+=A=te.a,T-=O,y-=P,w-=E,S-=A,te=te.next,h+=t}}const Blur=function a(e){var n=Math.round(this.blurRadius());n>0&&filterGaussBlurRGBA(e,n)};Factory.addGetterSetter(Node,"blurRadius",0,getNumberValidator(),Factory.afterSetFilter);const Brighten=function(a){var e=this.brightness()*255,n=a.data,t=n.length,r;for(r=0;r<t;r+=4)n[r]+=e,n[r+1]+=e,n[r+2]+=e};Factory.addGetterSetter(Node,"brightness",0,getNumberValidator(),Factory.afterSetFilter);const Contrast=function(a){var e=Math.pow((this.contrast()+100)/100,2),n=a.data,t=n.length,r=150,o=150,s=150,l;for(l=0;l<t;l+=4)r=n[l],o=n[l+1],s=n[l+2],r/=255,r-=.5,r*=e,r+=.5,r*=255,o/=255,o-=.5,o*=e,o+=.5,o*=255,s/=255,s-=.5,s*=e,s+=.5,s*=255,r=r<0?0:r>255?255:r,o=o<0?0:o>255?255:o,s=s<0?0:s>255?255:s,n[l]=r,n[l+1]=o,n[l+2]=s};Factory.addGetterSetter(Node,"contrast",0,getNumberValidator(),Factory.afterSetFilter);const Emboss=function(a){var e=this.embossStrength()*10,n=this.embossWhiteLevel()*255,t=this.embossDirection(),r=this.embossBlend(),o=0,s=0,l=a.data,c=a.width,f=a.height,h=c*4,u=f;switch(t){case"top-left":o=-1,s=-1;break;case"top":o=-1,s=0;break;case"top-right":o=-1,s=1;break;case"right":o=0,s=1;break;case"bottom-right":o=1,s=1;break;case"bottom":o=1,s=0;break;case"bottom-left":o=1,s=-1;break;case"left":o=0,s=-1;break;default:Util.error("Unknown emboss direction: "+t)}do{var i=(u-1)*h,d=o;u+d<1&&(d=0),u+d>f&&(d=0);var p=(u-1+d)*c*4,_=c;do{var m=i+(_-1)*4,g=s;_+g<1&&(g=0),_+g>c&&(g=0);var b=p+(_-1+g)*4,v=l[m]-l[b],T=l[m+1]-l[b+1],y=l[m+2]-l[b+2],w=v,S=w>0?w:-w,O=T>0?T:-T,P=y>0?y:-y;if(O>S&&(w=T),P>S&&(w=y),w*=e,r){var E=l[m]+w,A=l[m+1]+w,$=l[m+2]+w;l[m]=E>255?255:E<0?0:E,l[m+1]=A>255?255:A<0?0:A,l[m+2]=$>255?255:$<0?0:$}else{var k=n-w;k<0?k=0:k>255&&(k=255),l[m]=l[m+1]=l[m+2]=k}}while(--_)}while(--u)};Factory.addGetterSetter(Node,"embossStrength",.5,getNumberValidator(),Factory.afterSetFilter);Factory.addGetterSetter(Node,"embossWhiteLevel",.5,getNumberValidator(),Factory.afterSetFilter);Factory.addGetterSetter(Node,"embossDirection","top-left",null,Factory.afterSetFilter);Factory.addGetterSetter(Node,"embossBlend",!1,null,Factory.afterSetFilter);function remap(a,e,n,t,r){var o=n-e,s=r-t,l;return o===0?t+s/2:s===0?t:(l=(a-e)/o,l=s*l+t,l)}const Enhance=function(a){var e=a.data,n=e.length,t=e[0],r=t,o,s=e[1],l=s,c,f=e[2],h=f,u,i,d=this.enhance();if(d!==0){for(i=0;i<n;i+=4)o=e[i+0],o<t?t=o:o>r&&(r=o),c=e[i+1],c<s?s=c:c>l&&(l=c),u=e[i+2],u<f?f=u:u>h&&(h=u);r===t&&(r=255,t=0),l===s&&(l=255,s=0),h===f&&(h=255,f=0);var p,_,m,g,b,v,T,y,w;for(d>0?(_=r+d*(255-r),m=t-d*(t-0),b=l+d*(255-l),v=s-d*(s-0),y=h+d*(255-h),w=f-d*(f-0)):(p=(r+t)*.5,_=r+d*(r-p),m=t+d*(t-p),g=(l+s)*.5,b=l+d*(l-g),v=s+d*(s-g),T=(h+f)*.5,y=h+d*(h-T),w=f+d*(f-T)),i=0;i<n;i+=4)e[i+0]=remap(e[i+0],t,r,m,_),e[i+1]=remap(e[i+1],s,l,v,b),e[i+2]=remap(e[i+2],f,h,w,y)}};Factory.addGetterSetter(Node,"enhance",0,getNumberValidator(),Factory.afterSetFilter);const Grayscale=function(a){var e=a.data,n=e.length,t,r;for(t=0;t<n;t+=4)r=.34*e[t]+.5*e[t+1]+.16*e[t+2],e[t]=r,e[t+1]=r,e[t+2]=r};Factory.addGetterSetter(Node,"hue",0,getNumberValidator(),Factory.afterSetFilter);Factory.addGetterSetter(Node,"saturation",0,getNumberValidator(),Factory.afterSetFilter);Factory.addGetterSetter(Node,"luminance",0,getNumberValidator(),Factory.afterSetFilter);const HSL=function(a){var e=a.data,n=e.length,t=1,r=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,s=this.luminance()*127,l,c=t*r*Math.cos(o*Math.PI/180),f=t*r*Math.sin(o*Math.PI/180),h=.299*t+.701*c+.167*f,u=.587*t-.587*c+.33*f,i=.114*t-.114*c-.497*f,d=.299*t-.299*c-.328*f,p=.587*t+.413*c+.035*f,_=.114*t-.114*c+.293*f,m=.299*t-.3*c+1.25*f,g=.587*t-.586*c-1.05*f,b=.114*t+.886*c-.2*f,v,T,y,w;for(l=0;l<n;l+=4)v=e[l+0],T=e[l+1],y=e[l+2],w=e[l+3],e[l+0]=h*v+u*T+i*y+s,e[l+1]=d*v+p*T+_*y+s,e[l+2]=m*v+g*T+b*y+s,e[l+3]=w},HSV=function(a){var e=a.data,n=e.length,t=Math.pow(2,this.value()),r=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,s,l=t*r*Math.cos(o*Math.PI/180),c=t*r*Math.sin(o*Math.PI/180),f=.299*t+.701*l+.167*c,h=.587*t-.587*l+.33*c,u=.114*t-.114*l-.497*c,i=.299*t-.299*l-.328*c,d=.587*t+.413*l+.035*c,p=.114*t-.114*l+.293*c,_=.299*t-.3*l+1.25*c,m=.587*t-.586*l-1.05*c,g=.114*t+.886*l-.2*c,b,v,T,y;for(s=0;s<n;s+=4)b=e[s+0],v=e[s+1],T=e[s+2],y=e[s+3],e[s+0]=f*b+h*v+u*T,e[s+1]=i*b+d*v+p*T,e[s+2]=_*b+m*v+g*T,e[s+3]=y};Factory.addGetterSetter(Node,"hue",0,getNumberValidator(),Factory.afterSetFilter);Factory.addGetterSetter(Node,"saturation",0,getNumberValidator(),Factory.afterSetFilter);Factory.addGetterSetter(Node,"value",0,getNumberValidator(),Factory.afterSetFilter);const Invert=function(a){var e=a.data,n=e.length,t;for(t=0;t<n;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]};var ToPolar=function(a,e,n){var t=a.data,r=e.data,o=a.width,s=a.height,l=n.polarCenterX||o/2,c=n.polarCenterY||s/2,f,h,u,i=0,d=0,p=0,_=0,m,g=Math.sqrt(l*l+c*c);h=o-l,u=s-c,m=Math.sqrt(h*h+u*u),g=m>g?m:g;var b=s,v=o,T,y,w=360/v*Math.PI/180,S,O;for(y=0;y<v;y+=1)for(S=Math.sin(y*w),O=Math.cos(y*w),T=0;T<b;T+=1)h=Math.floor(l+g*T/b*O),u=Math.floor(c+g*T/b*S),f=(u*o+h)*4,i=t[f+0],d=t[f+1],p=t[f+2],_=t[f+3],f=(y+T*o)*4,r[f+0]=i,r[f+1]=d,r[f+2]=p,r[f+3]=_},FromPolar=function(a,e,n){var t=a.data,r=e.data,o=a.width,s=a.height,l=n.polarCenterX||o/2,c=n.polarCenterY||s/2,f,h,u,i,d,p=0,_=0,m=0,g=0,b,v=Math.sqrt(l*l+c*c);h=o-l,u=s-c,b=Math.sqrt(h*h+u*u),v=b>v?b:v;var T=s,y=o,w,S,O=n.polarRotation||0,P,E;for(h=0;h<o;h+=1)for(u=0;u<s;u+=1)i=h-l,d=u-c,w=Math.sqrt(i*i+d*d)*T/v,S=(Math.atan2(d,i)*180/Math.PI+360+O)%360,S=S*y/360,P=Math.floor(S),E=Math.floor(w),f=(E*o+P)*4,p=t[f+0],_=t[f+1],m=t[f+2],g=t[f+3],f=(u*o+h)*4,r[f+0]=p,r[f+1]=_,r[f+2]=m,r[f+3]=g};const Kaleidoscope=function(a){var e=a.width,n=a.height,t,r,o,s,l,c,f,h,u,i,d=Math.round(this.kaleidoscopePower()),p=Math.round(this.kaleidoscopeAngle()),_=Math.floor(e*(p%360)/360);if(!(d<1)){var m=Util.createCanvasElement();m.width=e,m.height=n;var g=m.getContext("2d").getImageData(0,0,e,n);Util.releaseCanvas(m),ToPolar(a,g,{polarCenterX:e/2,polarCenterY:n/2});for(var b=e/Math.pow(2,d);b<=8;)b=b*2,d-=1;b=Math.ceil(b);var v=b,T=0,y=v,w=1;for(_+b>e&&(T=v,y=0,w=-1),r=0;r<n;r+=1)for(t=T;t!==y;t+=w)o=Math.round(t+_)%e,u=(e*r+o)*4,l=g.data[u+0],c=g.data[u+1],f=g.data[u+2],h=g.data[u+3],i=(e*r+t)*4,g.data[i+0]=l,g.data[i+1]=c,g.data[i+2]=f,g.data[i+3]=h;for(r=0;r<n;r+=1)for(v=Math.floor(b),s=0;s<d;s+=1){for(t=0;t<v+1;t+=1)u=(e*r+t)*4,l=g.data[u+0],c=g.data[u+1],f=g.data[u+2],h=g.data[u+3],i=(e*r+v*2-t-1)*4,g.data[i+0]=l,g.data[i+1]=c,g.data[i+2]=f,g.data[i+3]=h;v*=2}FromPolar(g,a,{polarRotation:0})}};Factory.addGetterSetter(Node,"kaleidoscopePower",2,getNumberValidator(),Factory.afterSetFilter);Factory.addGetterSetter(Node,"kaleidoscopeAngle",0,getNumberValidator(),Factory.afterSetFilter);function pixelAt(a,e,n){var t=(n*a.width+e)*4,r=[];return r.push(a.data[t++],a.data[t++],a.data[t++],a.data[t++]),r}function rgbDistance(a,e){return Math.sqrt(Math.pow(a[0]-e[0],2)+Math.pow(a[1]-e[1],2)+Math.pow(a[2]-e[2],2))}function rgbMean(a){for(var e=[0,0,0],n=0;n<a.length;n++)e[0]+=a[n][0],e[1]+=a[n][1],e[2]+=a[n][2];return e[0]/=a.length,e[1]/=a.length,e[2]/=a.length,e}function backgroundMask(a,e){var n=pixelAt(a,0,0),t=pixelAt(a,a.width-1,0),r=pixelAt(a,0,a.height-1),o=pixelAt(a,a.width-1,a.height-1),s=e||10;if(rgbDistance(n,t)<s&&rgbDistance(t,o)<s&&rgbDistance(o,r)<s&&rgbDistance(r,n)<s){for(var l=rgbMean([t,n,o,r]),c=[],f=0;f<a.width*a.height;f++){var h=rgbDistance(l,[a.data[f*4],a.data[f*4+1],a.data[f*4+2]]);c[f]=h<s?0:255}return c}}function applyMask(a,e){for(var n=0;n<a.width*a.height;n++)a.data[4*n+3]=e[n]}function erodeMask(a,e,n){for(var t=[1,1,1,1,0,1,1,1,1],r=Math.round(Math.sqrt(t.length)),o=Math.floor(r/2),s=[],l=0;l<n;l++)for(var c=0;c<e;c++){for(var f=l*e+c,h=0,u=0;u<r;u++)for(var i=0;i<r;i++){var d=l+u-o,p=c+i-o;if(d>=0&&d<n&&p>=0&&p<e){var _=d*e+p,m=t[u*r+i];h+=a[_]*m}}s[f]=h===255*8?255:0}return s}function dilateMask(a,e,n){for(var t=[1,1,1,1,1,1,1,1,1],r=Math.round(Math.sqrt(t.length)),o=Math.floor(r/2),s=[],l=0;l<n;l++)for(var c=0;c<e;c++){for(var f=l*e+c,h=0,u=0;u<r;u++)for(var i=0;i<r;i++){var d=l+u-o,p=c+i-o;if(d>=0&&d<n&&p>=0&&p<e){var _=d*e+p,m=t[u*r+i];h+=a[_]*m}}s[f]=h>=255*4?255:0}return s}function smoothEdgeMask(a,e,n){for(var t=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],r=Math.round(Math.sqrt(t.length)),o=Math.floor(r/2),s=[],l=0;l<n;l++)for(var c=0;c<e;c++){for(var f=l*e+c,h=0,u=0;u<r;u++)for(var i=0;i<r;i++){var d=l+u-o,p=c+i-o;if(d>=0&&d<n&&p>=0&&p<e){var _=d*e+p,m=t[u*r+i];h+=a[_]*m}}s[f]=h}return s}const Mask=function(a){var e=this.threshold(),n=backgroundMask(a,e);return n&&(n=erodeMask(n,a.width,a.height),n=dilateMask(n,a.width,a.height),n=smoothEdgeMask(n,a.width,a.height),applyMask(a,n)),a};Factory.addGetterSetter(Node,"threshold",0,getNumberValidator(),Factory.afterSetFilter);const Noise=function(a){var e=this.noise()*255,n=a.data,t=n.length,r=e/2,o;for(o=0;o<t;o+=4)n[o+0]+=r-2*r*Math.random(),n[o+1]+=r-2*r*Math.random(),n[o+2]+=r-2*r*Math.random()};Factory.addGetterSetter(Node,"noise",.2,getNumberValidator(),Factory.afterSetFilter);const Pixelate=function(a){var e=Math.ceil(this.pixelSize()),n=a.width,t=a.height,r,o,s,l,c,f,h,u=Math.ceil(n/e),i=Math.ceil(t/e),d,p,_,m,g,b,v,T=a.data;if(e<=0){Util.error("pixelSize value can not be <= 0");return}for(g=0;g<u;g+=1)for(b=0;b<i;b+=1){for(l=0,c=0,f=0,h=0,d=g*e,p=d+e,_=b*e,m=_+e,v=0,r=d;r<p;r+=1)if(!(r>=n))for(o=_;o<m;o+=1)o>=t||(s=(n*o+r)*4,l+=T[s+0],c+=T[s+1],f+=T[s+2],h+=T[s+3],v+=1);for(l=l/v,c=c/v,f=f/v,h=h/v,r=d;r<p;r+=1)if(!(r>=n))for(o=_;o<m;o+=1)o>=t||(s=(n*o+r)*4,T[s+0]=l,T[s+1]=c,T[s+2]=f,T[s+3]=h)}};Factory.addGetterSetter(Node,"pixelSize",8,getNumberValidator(),Factory.afterSetFilter);const Posterize=function(a){var e=Math.round(this.levels()*254)+1,n=a.data,t=n.length,r=255/e,o;for(o=0;o<t;o+=1)n[o]=Math.floor(n[o]/r)*r};Factory.addGetterSetter(Node,"levels",.5,getNumberValidator(),Factory.afterSetFilter);const RGB=function(a){var e=a.data,n=e.length,t=this.red(),r=this.green(),o=this.blue(),s,l;for(s=0;s<n;s+=4)l=(.34*e[s]+.5*e[s+1]+.16*e[s+2])/255,e[s]=l*t,e[s+1]=l*r,e[s+2]=l*o,e[s+3]=e[s+3]};Factory.addGetterSetter(Node,"red",0,function(a){return this._filterUpToDate=!1,a>255?255:a<0?0:Math.round(a)});Factory.addGetterSetter(Node,"green",0,function(a){return this._filterUpToDate=!1,a>255?255:a<0?0:Math.round(a)});Factory.addGetterSetter(Node,"blue",0,RGBComponent,Factory.afterSetFilter);const RGBA=function(a){var e=a.data,n=e.length,t=this.red(),r=this.green(),o=this.blue(),s=this.alpha(),l,c;for(l=0;l<n;l+=4)c=1-s,e[l]=t*s+e[l]*c,e[l+1]=r*s+e[l+1]*c,e[l+2]=o*s+e[l+2]*c};Factory.addGetterSetter(Node,"red",0,function(a){return this._filterUpToDate=!1,a>255?255:a<0?0:Math.round(a)});Factory.addGetterSetter(Node,"green",0,function(a){return this._filterUpToDate=!1,a>255?255:a<0?0:Math.round(a)});Factory.addGetterSetter(Node,"blue",0,RGBComponent,Factory.afterSetFilter);Factory.addGetterSetter(Node,"alpha",1,function(a){return this._filterUpToDate=!1,a>1?1:a<0?0:a});const Sepia=function(a){var e=a.data,n=e.length,t,r,o,s;for(t=0;t<n;t+=4)r=e[t+0],o=e[t+1],s=e[t+2],e[t+0]=Math.min(255,r*.393+o*.769+s*.189),e[t+1]=Math.min(255,r*.349+o*.686+s*.168),e[t+2]=Math.min(255,r*.272+o*.534+s*.131)},Solarize=function(a){var e=a.data,n=a.width,t=a.height,r=n*4,o=t;do{var s=(o-1)*r,l=n;do{var c=s+(l-1)*4,f=e[c],h=e[c+1],u=e[c+2];f>127&&(f=255-f),h>127&&(h=255-h),u>127&&(u=255-u),e[c]=f,e[c+1]=h,e[c+2]=u}while(--l)}while(--o)},Threshold=function(a){var e=this.threshold()*255,n=a.data,t=n.length,r;for(r=0;r<t;r+=1)n[r]=n[r]<e?0:255};Factory.addGetterSetter(Node,"threshold",.5,getNumberValidator(),Factory.afterSetFilter);const Konva=Konva$1.Util._assign(Konva$1,{Arc,Arrow,Circle:Circle$1,Ellipse,Image:Image$2,Label:Label$1,Tag:Tag$1,Line:Line$1,Path,Rect:Rect$1,RegularPolygon,Ring,Sprite,Star,Text:Text$1,TextPath,Transformer,Wedge,Filters:{Blur,Brighten,Contrast,Emboss,Enhance,Grayscale,HSL,HSV,Invert,Kaleidoscope,Mask,Noise,Pixelate,Posterize,RGB,RGBA,Sepia,Solarize,Threshold}}),KONVA_EVENTS=["mouseover","mouseout","mouseenter","mouseleave","mousemove","mousedown","mouseup","wheel","click","dblclick","touchstart","touchmove","touchend","tap","dbltap","pointerdown","pointermove","pointerup","pointercancel","pointerover","pointerenter","pointerout","pointerleave","pointerclick","pointerdblclick","dragstart","dragmove","dragend","transformstart","transform","transformend"];function registerEvents(a,e){KONVA_EVENTS.forEach(n=>{e.on(n,t=>{a(n,t,{cancelable:!0})||(t.cancelBubble=!0)})})}const CONTAINER_COMPONENT_KEYS=["svelte-konva-stage","svelte-konva-layer","svelte-konva-group","svelte-konva-label"];var Container;(function(a){a[a.Stage=0]="Stage",a[a.Layer=1]="Layer",a[a.Group=2]="Group",a[a.Label=3]="Label"})(Container||(Container={}));const CONTAINER_ERROR="svelte-konva: Component does not have any parent container. Please make sure that the component is wrapped inside a Layer or Group.",LAYER_ERROR="svelte-konva: A Layer needs to have a Stage as parent.";function setContainerContext(a,e){CONTAINER_COMPONENT_KEYS.forEach(n=>{setContext(n,null)}),setContext(CONTAINER_COMPONENT_KEYS[a],e)}function getParentContainer(){for(let a=1;a<4;a++){const e=getContext(CONTAINER_COMPONENT_KEYS[a]);if(e)return e}throw new Error(CONTAINER_ERROR)}function getParentStage(){const a=getContext(CONTAINER_COMPONENT_KEYS[Container.Stage]);if(a)return a;throw new Error(LAYER_ERROR)}function copyExistingKeys(a,e){for(const n in a)Object.prototype.hasOwnProperty.call(e,n)&&(a[n]=e[n])}function instance$s(a,e,n){let t,{config:r}=e,{handle:o=new Konva.Circle(r)}=e,s=getParentContainer();component_subscribe(a,s,c=>n(3,t=c));let l=createEventDispatcher();return onMount(()=>{t.add(o),o.on("transformend",()=>{copyExistingKeys(r,o.getAttrs()),n(1,r)}),o.on("dragend",()=>{copyExistingKeys(r,o.getAttrs()),n(1,r)}),registerEvents(l,o)}),onDestroy(()=>{o.destroy()}),a.$$set=c=>{"config"in c&&n(1,r=c.config),"handle"in c&&n(2,o=c.handle)},a.$$.update=()=>{a.$$.dirty&6&&o.setAttrs(r)},[s,r,o]}class Circle extends SvelteComponent{constructor(e){super(),init(this,e,instance$s,null,safe_not_equal,{config:1,handle:2})}}function create_if_block$d(a){let e;const n=a[5].default,t=create_slot(n,a,a[4],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&16)&&update_slot_base(t,n,r,r[4],e?get_slot_changes(n,r[4],o,null):get_all_dirty_from_scope(r[4]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$n(a){let e,n,t=a[0]&&create_if_block$d(a);return{c(){t&&t.c(),e=empty()},l(r){t&&t.l(r),e=empty()},m(r,o){t&&t.m(r,o),insert_hydration(r,e,o),n=!0},p(r,[o]){r[0]?t?(t.p(r,o),o&1&&transition_in(t,1)):(t=create_if_block$d(r),t.c(),transition_in(t,1),t.m(e.parentNode,e)):t&&(group_outros(),transition_out(t,1,1,()=>{t=null}),check_outros())},i(r){n||(transition_in(t),n=!0)},o(r){transition_out(t),n=!1},d(r){r&&detach(e),t&&t.d(r)}}}function instance$r(a,e,n){let t,{$$slots:r={},$$scope:o}=e,{config:s={}}=e,{handle:l=new Konva.Group(s)}=e,c=writable(null),f=createEventDispatcher(),h=!1,u=getParentContainer();return component_subscribe(a,u,i=>n(6,t=i)),onMount(()=>{t.add(l),l.on("transformend",()=>{copyExistingKeys(s,l.getAttrs()),n(2,s)}),l.on("dragend",()=>{copyExistingKeys(s,l.getAttrs()),n(2,s)}),registerEvents(f,l),c.set(l),n(0,h=!0)}),onDestroy(()=>{l&&l.destroy()}),setContainerContext(Container.Group,c),a.$$set=i=>{"config"in i&&n(2,s=i.config),"handle"in i&&n(3,l=i.handle),"$$scope"in i&&n(4,o=i.$$scope)},a.$$.update=()=>{a.$$.dirty&12&&l&&l.setAttrs(s)},[h,u,s,l,o,r]}class Group extends SvelteComponent{constructor(e){super(),init(this,e,instance$r,create_fragment$n,safe_not_equal,{config:2,handle:3})}}function instance$q(a,e,n){let t,{config:r}=e,{handle:o=new Konva.Image(r)}=e,s=getParentContainer();component_subscribe(a,s,c=>n(3,t=c));let l=createEventDispatcher();return onMount(()=>{t.add(o),o.on("transformend",()=>{copyExistingKeys(r,o.getAttrs()),n(1,r)}),o.on("dragend",()=>{copyExistingKeys(r,o.getAttrs()),n(1,r)}),registerEvents(l,o)}),onDestroy(()=>{o.destroy()}),a.$$set=c=>{"config"in c&&n(1,r=c.config),"handle"in c&&n(2,o=c.handle)},a.$$.update=()=>{a.$$.dirty&6&&o.setAttrs(r)},[s,r,o]}let Image$1=class extends SvelteComponent{constructor(e){super(),init(this,e,instance$q,null,safe_not_equal,{config:1,handle:2})}};function create_if_block$c(a){let e;const n=a[5].default,t=create_slot(n,a,a[4],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&16)&&update_slot_base(t,n,r,r[4],e?get_slot_changes(n,r[4],o,null):get_all_dirty_from_scope(r[4]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$m(a){let e,n,t=a[0]&&create_if_block$c(a);return{c(){t&&t.c(),e=empty()},l(r){t&&t.l(r),e=empty()},m(r,o){t&&t.m(r,o),insert_hydration(r,e,o),n=!0},p(r,[o]){r[0]?t?(t.p(r,o),o&1&&transition_in(t,1)):(t=create_if_block$c(r),t.c(),transition_in(t,1),t.m(e.parentNode,e)):t&&(group_outros(),transition_out(t,1,1,()=>{t=null}),check_outros())},i(r){n||(transition_in(t),n=!0)},o(r){transition_out(t),n=!1},d(r){r&&detach(e),t&&t.d(r)}}}function instance$p(a,e,n){let t,{$$slots:r={},$$scope:o}=e,{config:s}=e,{handle:l=new Konva.Label(s)}=e,c=writable(null),f=createEventDispatcher(),h=!1,u=getParentContainer();return component_subscribe(a,u,i=>n(6,t=i)),onMount(()=>{t.add(l),l.on("transformend",()=>{copyExistingKeys(s,l.getAttrs()),n(2,s)}),l.on("dragend",()=>{copyExistingKeys(s,l.getAttrs()),n(2,s)}),registerEvents(f,l),c.set(l),n(0,h=!0)}),onDestroy(()=>{l.destroy()}),setContainerContext(Container.Label,c),a.$$set=i=>{"config"in i&&n(2,s=i.config),"handle"in i&&n(3,l=i.handle),"$$scope"in i&&n(4,o=i.$$scope)},a.$$.update=()=>{a.$$.dirty&12&&l.setAttrs(s)},[h,u,s,l,o,r]}class Label extends SvelteComponent{constructor(e){super(),init(this,e,instance$p,create_fragment$m,safe_not_equal,{config:2,handle:3})}}function create_if_block$b(a){let e;const n=a[5].default,t=create_slot(n,a,a[4],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&16)&&update_slot_base(t,n,r,r[4],e?get_slot_changes(n,r[4],o,null):get_all_dirty_from_scope(r[4]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$l(a){let e,n,t=a[0]&&create_if_block$b(a);return{c(){t&&t.c(),e=empty()},l(r){t&&t.l(r),e=empty()},m(r,o){t&&t.m(r,o),insert_hydration(r,e,o),n=!0},p(r,[o]){r[0]?t?(t.p(r,o),o&1&&transition_in(t,1)):(t=create_if_block$b(r),t.c(),transition_in(t,1),t.m(e.parentNode,e)):t&&(group_outros(),transition_out(t,1,1,()=>{t=null}),check_outros())},i(r){n||(transition_in(t),n=!0)},o(r){transition_out(t),n=!1},d(r){r&&detach(e),t&&t.d(r)}}}function instance$o(a,e,n){let t,{$$slots:r={},$$scope:o}=e,{config:s={}}=e,{handle:l=new Konva.Layer(s)}=e,c=writable(null),f=createEventDispatcher(),h=!1,u=getParentStage();return component_subscribe(a,u,i=>n(6,t=i)),onMount(()=>{t.add(l),l.on("transformend",()=>{copyExistingKeys(s,l.getAttrs()),n(2,s)}),l.on("dragend",()=>{copyExistingKeys(s,l.getAttrs()),n(2,s)}),registerEvents(f,l),c.set(l),n(0,h=!0)}),onDestroy(()=>{l&&l.destroy()}),setContainerContext(Container.Layer,c),a.$$set=i=>{"config"in i&&n(2,s=i.config),"handle"in i&&n(3,l=i.handle),"$$scope"in i&&n(4,o=i.$$scope)},a.$$.update=()=>{a.$$.dirty&12&&l&&l.setAttrs(s)},[h,u,s,l,o,r]}class Layer extends SvelteComponent{constructor(e){super(),init(this,e,instance$o,create_fragment$l,safe_not_equal,{config:2,handle:3})}}function instance$n(a,e,n){let t,{config:r}=e,{handle:o=new Konva.Line(r)}=e,s=getParentContainer();component_subscribe(a,s,c=>n(3,t=c));let l=createEventDispatcher();return onMount(()=>{t.add(o),o.on("transformend",()=>{copyExistingKeys(r,o.getAttrs()),n(1,r)}),o.on("dragend",()=>{copyExistingKeys(r,o.getAttrs()),n(1,r)}),registerEvents(l,o)}),onDestroy(()=>{o.destroy()}),a.$$set=c=>{"config"in c&&n(1,r=c.config),"handle"in c&&n(2,o=c.handle)},a.$$.update=()=>{a.$$.dirty&6&&o.setAttrs(r)},[s,r,o]}class Line extends SvelteComponent{constructor(e){super(),init(this,e,instance$n,null,safe_not_equal,{config:1,handle:2})}}function instance$m(a,e,n){let t,{config:r}=e,{handle:o=new Konva.Rect(r)}=e,s=getParentContainer();component_subscribe(a,s,c=>n(3,t=c));let l=createEventDispatcher();return onMount(()=>{t.add(o),o.on("transformend",()=>{copyExistingKeys(r,o.getAttrs()),n(1,r)}),o.on("dragend",()=>{copyExistingKeys(r,o.getAttrs()),n(1,r)}),registerEvents(l,o)}),onDestroy(()=>{o.destroy()}),a.$$set=c=>{"config"in c&&n(1,r=c.config),"handle"in c&&n(2,o=c.handle)},a.$$.update=()=>{a.$$.dirty&6&&o.setAttrs(r)},[s,r,o]}class Rect extends SvelteComponent{constructor(e){super(),init(this,e,instance$m,null,safe_not_equal,{config:1,handle:2})}}function instance$l(a,e,n){let t,{config:r}=e,{handle:o=new Konva.Shape(r)}=e,s=getParentContainer();component_subscribe(a,s,c=>n(3,t=c));let l=createEventDispatcher();return onMount(()=>{t.add(o),o.on("transformend",()=>{copyExistingKeys(r,o.getAttrs()),n(1,r)}),o.on("dragend",()=>{copyExistingKeys(r,o.getAttrs()),n(1,r)}),registerEvents(l,o)}),onDestroy(()=>{o.destroy()}),a.$$set=c=>{"config"in c&&n(1,r=c.config),"handle"in c&&n(2,o=c.handle)},a.$$.update=()=>{a.$$.dirty&6&&o.setAttrs(r)},[s,r,o]}class Shape extends SvelteComponent{constructor(e){super(),init(this,e,instance$l,null,safe_not_equal,{config:1,handle:2})}}function create_if_block$a(a){let e;const n=a[6].default,t=create_slot(n,a,a[5],null);return{c(){t&&t.c()},l(r){t&&t.l(r)},m(r,o){t&&t.m(r,o),e=!0},p(r,o){t&&t.p&&(!e||o&32)&&update_slot_base(t,n,r,r[5],e?get_slot_changes(n,r[5],o,null):get_all_dirty_from_scope(r[5]),null)},i(r){e||(transition_in(t,r),e=!0)},o(r){transition_out(t,r),e=!1},d(r){t&&t.d(r)}}}function create_fragment$k(a){let e,n,t=a[1]&&create_if_block$a(a),r=[a[2]],o={};for(let s=0;s<r.length;s+=1)o=assign(o,r[s]);return{c(){e=element("div"),t&&t.c(),this.h()},l(s){e=claim_element(s,"DIV",{});var l=children(e);t&&t.l(l),l.forEach(detach),this.h()},h(){set_attributes(e,o)},m(s,l){insert_hydration(s,e,l),t&&t.m(e,null),a[7](e),n=!0},p(s,[l]){s[1]?t?(t.p(s,l),l&2&&transition_in(t,1)):(t=create_if_block$a(s),t.c(),transition_in(t,1),t.m(e,null)):t&&(group_outros(),transition_out(t,1,1,()=>{t=null}),check_outros()),set_attributes(e,o=get_spread_update(r,[l&4&&s[2]]))},i(s){n||(transition_in(t),n=!0)},o(s){transition_out(t),n=!1},d(s){s&&detach(e),t&&t.d(),a[7](null)}}}function instance$k(a,e,n){const t=["config","handle"];let r=compute_rest_props(e,t),{$$slots:o={},$$scope:s}=e,{config:l}=e,{handle:c=null}=e,f=writable(null),h,u=createEventDispatcher(),i=!1;onMount(()=>{n(4,c=new Konva.Stage({container:h,...l})),c.on("dragend",()=>{copyExistingKeys(l,c.getAttrs()),n(3,l)}),registerEvents(u,c),f.set(c),n(1,i=!0)}),onDestroy(()=>{c&&c.destroy()}),setContainerContext(Container.Stage,f);function d(p){binding_callbacks[p?"unshift":"push"](()=>{h=p,n(0,h)})}return a.$$set=p=>{e=assign(assign({},e),exclude_internal_props(p)),n(2,r=compute_rest_props(e,t)),"config"in p&&n(3,l=p.config),"handle"in p&&n(4,c=p.handle),"$$scope"in p&&n(5,s=p.$$scope)},a.$$.update=()=>{a.$$.dirty&24&&c&&c.setAttrs(l)},[h,i,r,l,c,s,o,d]}class Stage extends SvelteComponent{constructor(e){super(),init(this,e,instance$k,create_fragment$k,safe_not_equal,{config:3,handle:4})}}function instance$j(a,e,n){let t,{config:r}=e,{handle:o=new Konva.Text(r)}=e,s=getParentContainer();component_subscribe(a,s,c=>n(3,t=c));let l=createEventDispatcher();return onMount(()=>{t.add(o),o.on("transformend",()=>{copyExistingKeys(r,o.getAttrs()),n(1,r)}),o.on("dragend",()=>{copyExistingKeys(r,o.getAttrs()),n(1,r)}),registerEvents(l,o)}),onDestroy(()=>{o.destroy()}),a.$$set=c=>{"config"in c&&n(1,r=c.config),"handle"in c&&n(2,o=c.handle)},a.$$.update=()=>{a.$$.dirty&6&&o.setAttrs(r)},[s,r,o]}class Text extends SvelteComponent{constructor(e){super(),init(this,e,instance$j,null,safe_not_equal,{config:1,handle:2})}}function instance$i(a,e,n){let t,{config:r}=e,{handle:o=new Konva.Tag(r)}=e,s=getParentContainer();component_subscribe(a,s,c=>n(3,t=c));let l=createEventDispatcher();return onMount(()=>{t.add(o),o.on("transformend",()=>{copyExistingKeys(r,o.getAttrs()),n(1,r)}),o.on("dragend",()=>{copyExistingKeys(r,o.getAttrs()),n(1,r)}),registerEvents(l,o)}),onDestroy(()=>{o.destroy()}),a.$$set=c=>{"config"in c&&n(1,r=c.config),"handle"in c&&n(2,o=c.handle)},a.$$.update=()=>{a.$$.dirty&6&&o.setAttrs(r)},[s,r,o]}class Tag extends SvelteComponent{constructor(e){super(),init(this,e,instance$i,null,safe_not_equal,{config:1,handle:2})}}const INPUTPOINT_RADIUS=6,INPUTPOINT_STROKEWIDTH=3,INPUTRECT_STROKEWIDTH=1.5,BBOX_STROKEWIDTH=2,MASK_STROKEWIDTH=2,POINT_SELECTION="POINT_SELECTION";function addMask(a,e,n,t,r,o,s){const l=t.x(),c=t.y(),f=t.scale(),h=new Option().style;h.color=e;function u(p){const _=p.split(" "),m=_[0].slice(1);return{x:parseInt(m),y:parseInt(_[1])}}function i(p){const _=p.split(" "),m=_[2].slice(1),g=[{x:parseInt(m),y:parseInt(_[3])}];for(let b=4;b<_.length;b+=2)g.push({x:parseInt(_[b]),y:parseInt(_[b+1])});return g}const d=new Konva.Shape({id:a.id,x:l,y:c,width:o.width(),height:o.height(),fill:`rgba(${h.color.replace("rgb(","").replace(")","")}, 0.35)`,stroke:h.color,strokeWidth:MASK_STROKEWIDTH/s[r],scale:f,visible:a.visible,opacity:a.opacity,listening:!1,sceneFunc:(p,_)=>{p.beginPath();for(let m=0;m<a.svg.length;++m){const g=u(a.svg[m]);p.moveTo(g.x,g.y);const b=i(a.svg[m]);for(const v of b)p.lineTo(v.x,v.y)}p.fillStrokeShape(_)}});n.add(d)}function findOrCreateCurrentMask(a,e){const t=e.findOne(`#${a}`).findOne("#currentAnnotation");let r=t.findOne("#currentMask");return r||(r=new Konva.Group({id:"currentMask"}),t.add(r)),r}function clearCurrentAnn(a,e,n){const t=e==null?void 0:e.findOne(`#${a}`);if(t){const o=t.findOne("#currentAnnotation").findOne("#currentMask");o&&o.destroy(),n!=null&&n.postProcessor&&n.postProcessor.reset()}}var simplify$1={exports:{}};(function(a){(function(){function e(l,c){var f=l.x-c.x,h=l.y-c.y;return f*f+h*h}function n(l,c,f){var h=c.x,u=c.y,i=f.x-h,d=f.y-u;if(i!==0||d!==0){var p=((l.x-h)*i+(l.y-u)*d)/(i*i+d*d);p>1?(h=f.x,u=f.y):p>0&&(h+=i*p,u+=d*p)}return i=l.x-h,d=l.y-u,i*i+d*d}function t(l,c){for(var f=l[0],h=[f],u,i=1,d=l.length;i<d;i++)u=l[i],e(u,f)>c&&(h.push(u),f=u);return f!==u&&h.push(u),h}function r(l,c,f,h,u){for(var i=h,d,p=c+1;p<f;p++){var _=n(l[p],l[c],l[f]);_>i&&(d=p,i=_)}i>h&&(d-c>1&&r(l,c,d,h,u),u.push(l[d]),f-d>1&&r(l,d,f,h,u))}function o(l,c){var f=l.length-1,h=[l[0]];return r(l,0,f,c,h),h.push(l[f]),h}function s(l,c,f){if(l.length<=2)return l;var h=c!==void 0?c*c:1;return l=f?l:t(l,h),l=o(l,h),l}a.exports=s,a.exports.default=s})()})(simplify$1);var simplifyExports=simplify$1.exports;const simplify=getDefaultExportFromCjs(simplifyExports),parseSvgPath=a=>{const e=/([ML]?)\s*([\d.]+)\s+([\d.]+)/g;let n,t=[];for(;(n=e.exec(a))!==null;){const[,,r,o]=n;t.push({x:parseFloat(r),y:parseFloat(o)})}return t=simplify(t,4,!0),t.map((r,o)=>({...r,id:o}))},convertPointToSvg=a=>a.reduce((e,n,t)=>t===0?`M${n.x} ${n.y}`:t===1?`${e} L${n.x} ${n.y}`:`${e} ${n.x} ${n.y}`,""),hexToRGBA=(a,e)=>{const n=parseInt(a.slice(1,3),16),t=parseInt(a.slice(3,5),16),r=parseInt(a.slice(5,7),16);return`rgba(${n},${t},${r},${e})`};function m_part(a){const e=a.split(" "),n=e[0].slice(1);return{x:parseInt(n),y:parseInt(e[1])}}function l_part(a){var r;const e=a.split(" "),n=(r=e[2])==null?void 0:r.slice(1),t=[{x:parseInt(n),y:parseInt(e[3])}];for(let o=4;o<e.length;o+=2)t.push({x:parseInt(e[o]),y:parseInt(e[o+1])});return t}const sceneFunc=(a,e,n)=>{a.beginPath();for(let t=0;t<n.length;++t){const r=m_part(n[t]);a.moveTo(r.x,r.y);const o=l_part(n[t]);for(const s of o)a.lineTo(s.x,s.y)}a.fillStrokeShape(e)};function svgPathToBitmap(a,e,n){const t=document.createElement("canvas");t.width=e,t.height=n;const r=t.getContext("2d");r.clearRect(0,0,e,n),r.fillStyle="black",r.fill(new Path2D(a));const o=r.getImageData(0,0,e,n).data,s=[];for(let l=0;l<o.length;l+=4)s.push(o[l+3]===0?0:1);return s}function rleEncode(a){const e=[];let n=1;for(let t=1;t<a.length;t++)a[t]===a[t-1]?n++:(e.push(n),n=1);return e.push(n),e}function reshapeArray(a,e,n){if(a.length!==e*n)throw new Error("Can't reshape with length != cols*rows");const t=[];for(let r=0;r<n;r++)for(let o=0;o<e;o++)t.push(a[o*n+r]);return t}function runLengthEncode(a,e,n){let t=svgPathToBitmap(a,e,n);return t=reshapeArray(t,n,e),rleEncode(t)}function get_each_context$5(a,e,n){const t=a.slice();return t[14]=e[n],t[16]=n,t}function get_each_context_1$1(a,e,n){const t=a.slice();return t[17]=e[n],t[19]=n,t}function create_each_block_1$1(a){let e,n;function t(){return a[9](a[19])}function r(){return a[10](a[17],a[16])}function o(...l){return a[12](a[16],a[17],...l)}function s(){return a[13](a[17],a[16])}return e=new Circle({props:{config:{x:a[17].x,y:a[17].y,radius:(a[19]===0?6:4)/a[1][a[0]],fill:a[19]===0?"#781e60":"rgb(0,128,0)",stroke:"white",strokeWidth:1/a[1][a[0]],id:`dot-${a[2]}-${a[16]}-${a[17].id}`,draggable:!0}}}),e.$on("click",t),e.$on("dragmove",r),e.$on("dragend",a[11]),e.$on("mouseover",o),e.$on("mouseleave",s),{c(){create_component(e.$$.fragment)},l(l){claim_component(e.$$.fragment,l)},m(l,c){mount_component(e,l,c),n=!0},p(l,c){a=l;const f={};c&15&&(f.config={x:a[17].x,y:a[17].y,radius:(a[19]===0?6:4)/a[1][a[0]],fill:a[19]===0?"#781e60":"rgb(0,128,0)",stroke:"white",strokeWidth:1/a[1][a[0]],id:`dot-${a[2]}-${a[16]}-${a[17].id}`,draggable:!0}),e.$set(f)},i(l){n||(transition_in(e.$$.fragment,l),n=!0)},o(l){transition_out(e.$$.fragment,l),n=!1},d(l){destroy_component(e,l)}}}function create_each_block$5(a){let e,n,t=ensure_array_like(a[14]),r=[];for(let s=0;s<t.length;s+=1)r[s]=create_each_block_1$1(get_each_context_1$1(a,t,s));const o=s=>transition_out(r[s],1,1,()=>{r[s]=null});return{c(){for(let s=0;s<r.length;s+=1)r[s].c();e=empty()},l(s){for(let l=0;l<r.length;l+=1)r[l].l(s);e=empty()},m(s,l){for(let c=0;c<r.length;c+=1)r[c]&&r[c].m(s,l);insert_hydration(s,e,l),n=!0},p(s,l){if(l&255){t=ensure_array_like(s[14]);let c;for(c=0;c<t.length;c+=1){const f=get_each_context_1$1(s,t,c);r[c]?(r[c].p(f,l),transition_in(r[c],1)):(r[c]=create_each_block_1$1(f),r[c].c(),transition_in(r[c],1),r[c].m(e.parentNode,e))}for(group_outros(),c=t.length;c<r.length;c+=1)o(c);check_outros()}},i(s){if(!n){for(let l=0;l<t.length;l+=1)transition_in(r[l]);n=!0}},o(s){r=r.filter(Boolean);for(let l=0;l<r.length;l+=1)transition_out(r[l]);n=!1},d(s){s&&detach(e),destroy_each(r,s)}}}function create_fragment$j(a){let e,n,t=ensure_array_like(a[3]),r=[];for(let s=0;s<t.length;s+=1)r[s]=create_each_block$5(get_each_context$5(a,t,s));const o=s=>transition_out(r[s],1,1,()=>{r[s]=null});return{c(){for(let s=0;s<r.length;s+=1)r[s].c();e=empty()},l(s){for(let l=0;l<r.length;l+=1)r[l].l(s);e=empty()},m(s,l){for(let c=0;c<r.length;c+=1)r[c]&&r[c].m(s,l);insert_hydration(s,e,l),n=!0},p(s,[l]){if(l&255){t=ensure_array_like(s[3]);let c;for(c=0;c<t.length;c+=1){const f=get_each_context$5(s,t,c);r[c]?(r[c].p(f,l),transition_in(r[c],1)):(r[c]=create_each_block$5(f),r[c].c(),transition_in(r[c],1),r[c].m(e.parentNode,e))}for(group_outros(),c=t.length;c<r.length;c+=1)o(c);check_outros()}},i(s){if(!n){for(let l=0;l<t.length;l+=1)transition_in(r[l]);n=!0}},o(s){r=r.filter(Boolean);for(let l=0;l<r.length;l+=1)transition_out(r[l]);n=!1},d(s){s&&detach(e),destroy_each(r,s)}}}function instance$h(a,e,n){let{viewId:t}=e,{stage:r}=e,{zoomFactor:o}=e,{polygonId:s}=e,{points:l}=e,{handlePolygonPointsClick:c}=e,{handlePolygonPointsDragMove:f}=e,{handlePolygonPointsDragEnd:h}=e;function u(g,b,v){const T=r.findOne(`#dot-${s}-${b}-${g}`);T.scaleX(v),T.scaleY(v)}const i=g=>c==null?void 0:c(g,t),d=(g,b)=>f==null?void 0:f(g.id,b),p=()=>h==null?void 0:h(),_=(g,b,v)=>{var T,y;((y=(T=v.detail.target)==null?void 0:T.attrs)==null?void 0:y.id)===`dot-${s}-${g}-${b.id}`&&u(b.id,g,2)},m=(g,b)=>u(g.id,b,1);return a.$$set=g=>{"viewId"in g&&n(0,t=g.viewId),"stage"in g&&n(8,r=g.stage),"zoomFactor"in g&&n(1,o=g.zoomFactor),"polygonId"in g&&n(2,s=g.polygonId),"points"in g&&n(3,l=g.points),"handlePolygonPointsClick"in g&&n(4,c=g.handlePolygonPointsClick),"handlePolygonPointsDragMove"in g&&n(5,f=g.handlePolygonPointsDragMove),"handlePolygonPointsDragEnd"in g&&n(6,h=g.handlePolygonPointsDragEnd)},[t,o,s,l,c,f,h,u,r,i,d,p,_,m]}class PolygonPoints extends SvelteComponent{constructor(e){super(),init(this,e,instance$h,create_fragment$j,safe_not_equal,{viewId:0,stage:8,zoomFactor:1,polygonId:2,points:3,handlePolygonPointsClick:4,handlePolygonPointsDragMove:5,handlePolygonPointsDragEnd:6})}}function create_else_block$2(a){let e,n;return e=new Shape({props:{config:{sceneFunc:a[16],stroke:a[3],strokeWidth:a[2].strokeFactor,closed:!0,fill:hexToRGBA(a[3],.5),id:a[2].id}}}),e.$on("dblclick",a[11]),e.$on("click",a[12]),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r&12&&(o.config={sceneFunc:t[16],stroke:t[3],strokeWidth:t[2].strokeFactor,closed:!0,fill:hexToRGBA(t[3],.5),id:t[2].id}),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_if_block$9(a){let e,n,t,r;return e=new Shape({props:{config:{sceneFunc:a[15],stroke:a[3],strokeWidth:2/a[4][a[0]],closed:!0,fill:hexToRGBA(a[3],.5)}}}),t=new PolygonPoints({props:{viewId:a[0],stage:a[1],zoomFactor:a[4],polygonId:a[2].id,points:a[6].simplifiedPoints,handlePolygonPointsClick:null,handlePolygonPointsDragMove:a[8],handlePolygonPointsDragEnd:a[9]}}),{c(){create_component(e.$$.fragment),n=space(),create_component(t.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(t.$$.fragment,o)},m(o,s){mount_component(e,o,s),insert_hydration(o,n,s),mount_component(t,o,s),r=!0},p(o,s){const l={};s&89&&(l.config={sceneFunc:o[15],stroke:o[3],strokeWidth:2/o[4][o[0]],closed:!0,fill:hexToRGBA(o[3],.5)}),e.$set(l);const c={};s&1&&(c.viewId=o[0]),s&2&&(c.stage=o[1]),s&16&&(c.zoomFactor=o[4]),s&4&&(c.polygonId=o[2].id),s&64&&(c.points=o[6].simplifiedPoints),t.$set(c)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(t.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(t.$$.fragment,o),r=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(t,o)}}}function create_default_slot$9(a){let e,n,t,r;const o=[create_if_block$9,create_else_block$2],s=[];function l(c,f){return c[7]?0:1}return e=l(a),n=s[e]=o[e](a),{c(){n.c(),t=empty()},l(c){n.l(c),t=empty()},m(c,f){s[e].m(c,f),insert_hydration(c,t,f),r=!0},p(c,f){let h=e;e=l(c),e===h?s[e].p(c,f):(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros(),n=s[e],n?n.p(c,f):(n=s[e]=o[e](c),n.c()),transition_in(n,1),n.m(t.parentNode,t))},i(c){r||(transition_in(n),r=!0)},o(c){transition_out(n),r=!1},d(c){c&&detach(t),s[e].d(c)}}}function create_fragment$i(a){let e,n;return e=new Group({props:{config:{id:`polygon-${a[2].id}`,draggable:a[7],visible:a[2].visible,opacity:a[2].opacity,listening:a[5].type==="PAN"},$$slots:{default:[create_default_slot$9]},$$scope:{ctx:a}}}),e.$on("dragend",a[17]),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,[r]){const o={};r&164&&(o.config={id:`polygon-${t[2].id}`,draggable:t[7],visible:t[2].visible,opacity:t[2].opacity,listening:t[5].type==="PAN"}),r&262367&&(o.$$scope={dirty:r,ctx:t}),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function instance$g(a,e,n){let{viewId:t}=e,{newShape:r}=e,{stage:o}=e,{currentImage:s}=e,{mask:l}=e,{color:c}=e,{zoomFactor:f}=e,{selectedTool:h}=e,u=!1,i={simplifiedSvg:l.svg,simplifiedPoints:l.svg.reduce((y,w)=>[...y,parseSvgPath(w)],[])};const d=(y,w)=>{const S=o.findOne(`#dot-${l.id}-${w}-${y}`).position(),O=i.simplifiedPoints.map((P,E)=>E===w?P.map(A=>A.id===y?{...A,x:S.x,y:S.y}:A):P);n(6,i.simplifiedPoints=O,i)},p=y=>{const w=runLengthEncode(y||i.simplifiedSvg,s.width,s.height);l.editing&&n(13,r={status:"editing",type:"mask",shapeId:l.id,counts:w})},_=y=>{if(y.id()!==`polygon-${l.id}`)return;const w=y.x(),S=y.y(),O=i.simplifiedPoints.map(A=>A.map($=>({...$,x:$.x+w,y:$.y+S})));o.findOne(`#polygon-${l.id}`).position({x:0,y:0}),n(6,i.simplifiedPoints=O,i);const E=i.simplifiedPoints.map(A=>convertPointToSvg(A));p(E)},m=()=>{n(13,r={status:"editing",shapeId:l.id,highlighted:"self",type:"none"})},g=()=>{l.highlighted!=="self"&&n(13,r={status:"editing",shapeId:l.id,highlighted:"all",type:"none"})},b=(y,w)=>sceneFunc(y,w,i.simplifiedSvg),v=(y,w)=>sceneFunc(y,w,l.svg),T=y=>_(y.detail.target);return a.$$set=y=>{"viewId"in y&&n(0,t=y.viewId),"newShape"in y&&n(13,r=y.newShape),"stage"in y&&n(1,o=y.stage),"currentImage"in y&&n(14,s=y.currentImage),"mask"in y&&n(2,l=y.mask),"color"in y&&n(3,c=y.color),"zoomFactor"in y&&n(4,f=y.zoomFactor),"selectedTool"in y&&n(5,h=y.selectedTool)},a.$$.update=()=>{a.$$.dirty&4&&n(7,u=l.editing),a.$$.dirty&4&&n(6,i.simplifiedPoints=l.svg.reduce((y,w)=>[...y,parseSvgPath(w)],[]),i),a.$$.dirty&64&&n(6,i.simplifiedSvg=i.simplifiedPoints.map(y=>convertPointToSvg(y)),i)},[t,o,l,c,f,h,i,u,d,p,_,m,g,r,s,b,v,T]}class PolygonGroup extends SvelteComponent{constructor(e){super(),init(this,e,instance$g,create_fragment$i,safe_not_equal,{viewId:0,newShape:13,stage:1,currentImage:14,mask:2,color:3,zoomFactor:4,selectedTool:5})}}function create_if_block$8(a){let e,n;return e=new Group({props:{config:{id:"polygon",draggable:!0},$$slots:{default:[create_default_slot$8]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r&2174&&(o.$$scope={dirty:r,ctx:t}),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_default_slot$8(a){let e,n,t,r;return e=new Line({props:{config:{points:a[6],stroke:"hsl(316deg 60% 29.41%)",strokeWidth:INPUTRECT_STROKEWIDTH/a[3][a[1]],fill:"#f9f4f773",closed:a[5]}}}),t=new PolygonPoints({props:{viewId:a[1],stage:a[2],zoomFactor:a[3],polygonId:POLYGON_ID,points:a[4],handlePolygonPointsClick:a[7],handlePolygonPointsDragMove:a[8],handlePolygonPointsDragEnd:null}}),{c(){create_component(e.$$.fragment),n=space(),create_component(t.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(t.$$.fragment,o)},m(o,s){mount_component(e,o,s),insert_hydration(o,n,s),mount_component(t,o,s),r=!0},p(o,s){const l={};s&106&&(l.config={points:o[6],stroke:"hsl(316deg 60% 29.41%)",strokeWidth:INPUTRECT_STROKEWIDTH/o[3][o[1]],fill:"#f9f4f773",closed:o[5]}),e.$set(l);const c={};s&2&&(c.viewId=o[1]),s&4&&(c.stage=o[2]),s&8&&(c.zoomFactor=o[3]),s&16&&(c.points=o[4]),t.$set(c)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(t.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(t.$$.fragment,o),r=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(t,o)}}}function create_fragment$h(a){let e,n,t="viewId"in a[0]&&a[0].viewId===a[1]&&create_if_block$8(a);return{c(){t&&t.c(),e=empty()},l(r){t&&t.l(r),e=empty()},m(r,o){t&&t.m(r,o),insert_hydration(r,e,o),n=!0},p(r,[o]){"viewId"in r[0]&&r[0].viewId===r[1]?t?(t.p(r,o),o&3&&transition_in(t,1)):(t=create_if_block$8(r),t.c(),transition_in(t,1),t.m(e.parentNode,e)):t&&(group_outros(),transition_out(t,1,1,()=>{t=null}),check_outros())},i(r){n||(transition_in(t),n=!0)},o(r){transition_out(t),n=!1},d(r){r&&detach(e),t&&t.d(r)}}}const POLYGON_ID="creating";function instance$f(a,e,n){let t,{viewId:r}=e,{selectedItemId:o}=e,{newShape:s}=e,{stage:l}=e,{currentImage:c}=e,{zoomFactor:f}=e,h=[],u=!1;function i(p,_){if(p===0){const m=h.map(b=>convertPointToSvg(b)),g=runLengthEncode(m,c.width,c.height);n(0,s={status:"saving",masksImageSVG:[],rle:{counts:g,size:[c.height,c.width]},type:"mask",viewId:_,itemId:o,imageWidth:c.width,imageHeight:c.height}),n(5,u=!0)}}function d(p,_){const m=l.findOne(`#dot-${POLYGON_ID}-${_}-${p}`).position(),g=h.map((b,v)=>v===_?b.map(T=>T.id===p?{...T,x:m.x,y:m.y}:T):b);n(4,h=g)}return a.$$set=p=>{"viewId"in p&&n(1,r=p.viewId),"selectedItemId"in p&&n(9,o=p.selectedItemId),"newShape"in p&&n(0,s=p.newShape),"stage"in p&&n(2,l=p.stage),"currentImage"in p&&n(10,c=p.currentImage),"zoomFactor"in p&&n(3,f=p.zoomFactor)},a.$$.update=()=>{var p,_;if(a.$$.dirty&17){if(s.status==="creating"&&s.type==="mask"){const m=s.points.at(-1),g=(p=h==null?void 0:h[0])==null?void 0:p.at(-1);m&&(m==null?void 0:m.id)!==(g==null?void 0:g.id)&&n(4,h=[[...h[0]||[],m]]),s.points.length===0&&n(4,h=[])}s.status==="none"&&(n(4,h=[]),n(5,u=!1))}a.$$.dirty&16&&n(6,t=(_=h[0])==null?void 0:_.reduce((m,g)=>[...m,g.x,g.y],[]))},[s,r,l,f,h,u,t,i,d,o,c]}class CreatePolygon extends SvelteComponent{constructor(e){super(),init(this,e,instance$f,create_fragment$h,safe_not_equal,{viewId:1,selectedItemId:9,newShape:0,stage:2,currentImage:10,zoomFactor:3})}}const toggleIsEditingBBox=(a,e,n)=>{const t=e.findOne(`#rect${n}`),r=e.findOne("#transformer");if(t){const o=r==null?void 0:r.nodes();r==null||r.nodes(a==="on"?[t]:[...o.filter(s=>s.id()!==t.id())])}else r==null||r.nodes([])},onDragMove=(a,e,n,t,r)=>{const s=e.findOne(`#${n}`).findOne(`#image-${n}`);if(!s)return;const l=s.getSize();a.target.x()<0&&t.x(0),a.target.x()>l.width-t.width()&&t.x(l.width-t.width()),a.target.y()<0&&t.y(0),a.target.y()>l.height-t.height()&&t.y(l.height-t.height());const c=e.findOne(`#tooltip${r}`);stickLabelsToRectangle(c,t)},getNewRectangleDimensions=(a,e,n)=>{const o=e.findOne(`#${n}`).findOne(`#image-${n}`).getSize(),s=a==null?void 0:a.width(),l=a==null?void 0:a.height(),c=o.width,f=o.height,h=(a==null?void 0:a.x())/c,u=(a==null?void 0:a.y())/f,i=s/c,d=l/f;return[h,u,i,d]},stickLabelsToRectangle=(a,e)=>{a.x(e.x()),a.y(e.y())};function create_default_slot$7(a){let e,n,t,r;return e=new Tag({props:{config:{fill:a[7],stroke:a[6]?a[7]:"transparent"}}}),t=new Text({props:{config:{id:`text${a[0]}`,x:0,y:0,text:a[6],fontSize:12,fontStyle:"100"}}}),{c(){create_component(e.$$.fragment),n=space(),create_component(t.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(t.$$.fragment,o)},m(o,s){mount_component(e,o,s),insert_hydration(o,n,s),mount_component(t,o,s),r=!0},p(o,s){const l={};s&192&&(l.config={fill:o[7],stroke:o[6]?o[7]:"transparent"}),e.$set(l);const c={};s&65&&(c.config={id:`text${o[0]}`,x:0,y:0,text:o[6],fontSize:12,fontStyle:"100"}),t.$set(c)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(t.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(t.$$.fragment,o),r=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(t,o)}}}function create_fragment$g(a){let e,n;return e=new Label({props:{config:{id:`tooltip${a[0]}`,x:a[1],y:a[2],width:500,height:50,offsetY:12,visible:a[3],scale:{x:1/a[4],y:1/a[4]},opacity:a[5]},$$slots:{default:[create_default_slot$7]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,[r]){const o={};r&63&&(o.config={id:`tooltip${t[0]}`,x:t[1],y:t[2],width:500,height:50,offsetY:12,visible:t[3],scale:{x:1/t[4],y:1/t[4]},opacity:t[5]}),r&449&&(o.$$scope={dirty:r,ctx:t}),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function instance$e(a,e,n){let{id:t}=e,{x:r}=e,{y:o}=e,{visible:s=!0}=e,{zoomFactor:l}=e,{opacity:c=1}=e,{tooltip:f}=e,{color:h}=e;return a.$$set=u=>{"id"in u&&n(0,t=u.id),"x"in u&&n(1,r=u.x),"y"in u&&n(2,o=u.y),"visible"in u&&n(3,s=u.visible),"zoomFactor"in u&&n(4,l=u.zoomFactor),"opacity"in u&&n(5,c=u.opacity),"tooltip"in u&&n(6,f=u.tooltip),"color"in u&&n(7,h=u.color)},[t,r,o,s,l,c,f,h]}class LabelTag extends SvelteComponent{constructor(e){super(),init(this,e,instance$e,create_fragment$g,safe_not_equal,{id:0,x:1,y:2,visible:3,zoomFactor:4,opacity:5,tooltip:6,color:7})}}function create_default_slot$6(a){let e,n,t,r;return e=new Rect({props:{config:{id:`rect${a[0].id}`,x:a[0].bbox[0],y:a[0].bbox[1],width:a[0].bbox[2],height:a[0].bbox[3],stroke:a[1](a[0].id),strokeWidth:a[0].strokeFactor*(BBOX_STROKEWIDTH/a[2]),opacity:a[0].opacity,visible:a[0].visible,draggable:a[0].editing}}}),t=new LabelTag({props:{id:a[0].id,x:a[0].bbox[0],y:a[0].bbox[1],visible:a[0].visible,zoomFactor:a[2],opacity:a[0].opacity,tooltip:a[0].tooltip,color:a[1](a[0].id)}}),{c(){create_component(e.$$.fragment),n=space(),create_component(t.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(t.$$.fragment,o)},m(o,s){mount_component(e,o,s),insert_hydration(o,n,s),mount_component(t,o,s),r=!0},p(o,s){const l={};s&7&&(l.config={id:`rect${o[0].id}`,x:o[0].bbox[0],y:o[0].bbox[1],width:o[0].bbox[2],height:o[0].bbox[3],stroke:o[1](o[0].id),strokeWidth:o[0].strokeFactor*(BBOX_STROKEWIDTH/o[2]),opacity:o[0].opacity,visible:o[0].visible,draggable:o[0].editing}),e.$set(l);const c={};s&1&&(c.id=o[0].id),s&1&&(c.x=o[0].bbox[0]),s&1&&(c.y=o[0].bbox[1]),s&1&&(c.visible=o[0].visible),s&4&&(c.zoomFactor=o[2]),s&1&&(c.opacity=o[0].opacity),s&1&&(c.tooltip=o[0].tooltip),s&3&&(c.color=o[1](o[0].id)),t.$set(c)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(t.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(t.$$.fragment,o),r=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(t,o)}}}function create_fragment$f(a){var t;let e,n;return e=new Group({props:{config:{listening:((t=a[3])==null?void 0:t.type)==="PAN",zIndex:2},$$slots:{default:[create_default_slot$6]},$$scope:{ctx:a}}}),e.$on("dblclick",a[4]),e.$on("click",a[5]),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,o){mount_component(e,r,o),n=!0},p(r,[o]){var l;const s={};o&8&&(s.config={listening:((l=r[3])==null?void 0:l.type)==="PAN",zIndex:2}),o&4103&&(s.$$scope={dirty:o,ctx:r}),e.$set(s)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function instance$d(a,e,n){let{stage:t}=e,{bbox:r}=e,{colorScale:o}=e,{zoomFactor:s}=e,{viewId:l}=e,{newShape:c}=e,{selectedTool:f}=e,h=t.findOne(`#rect${r.id}`);const u=_=>{const m=getNewRectangleDimensions(_,t,l);n(6,c={status:"editing",type:"rectangle",shapeId:r.id,coords:m})},i=()=>{const _=t.findOne(`#${l}`),m=h.getClientRect({skipTransform:!1,skipShadow:!0,skipStroke:!0,relativeTo:_});h.setAttrs({x:m.x,y:m.y,width:m.width,height:m.height,rotation:0,scaleX:1,scaleY:1});const g=t.findOne(`#tooltip${r.id}`);stickLabelsToRectangle(g,h)},d=()=>{n(6,c={status:"editing",shapeId:r.id,highlighted:"self",type:"none"})},p=()=>{r.highlighted!=="self"&&n(6,c={status:"editing",shapeId:r.id,highlighted:"all",type:"none"})};return onDestroy(()=>{const _=t.findOne("#transformer");_&&_.nodes([])}),afterUpdate(async()=>{await tick(),toggleIsEditingBBox(r.editing?"on":"off",t,r.id),h=t.findOne(`#${l}`).findOne(`#rect${r.id}`),h&&(h.on("dragmove",m=>onDragMove(m,t,l,h,r.id)),h.on("transform",()=>i()),h.on("transformend dragend",()=>{u(h)}))}),a.$$set=_=>{"stage"in _&&n(7,t=_.stage),"bbox"in _&&n(0,r=_.bbox),"colorScale"in _&&n(1,o=_.colorScale),"zoomFactor"in _&&n(2,s=_.zoomFactor),"viewId"in _&&n(8,l=_.viewId),"newShape"in _&&n(6,c=_.newShape),"selectedTool"in _&&n(3,f=_.selectedTool)},[r,o,s,f,d,p,c,t,l]}class Rectangle extends SvelteComponent{constructor(e){super(),init(this,e,instance$d,create_fragment$f,safe_not_equal,{stage:7,bbox:0,colorScale:1,zoomFactor:2,viewId:8,newShape:6,selectedTool:3})}}function create_if_block$7(a){let e,n,t;function r(s){a[11](s)}let o={config:{id:"drag-rect-group"},$$slots:{default:[create_default_slot$5]},$$scope:{ctx:a}};return a[3]!==void 0&&(o.handle=a[3]),e=new Group({props:o}),binding_callbacks.push(()=>bind(e,"handle",r)),{c(){create_component(e.$$.fragment)},l(s){claim_component(e.$$.fragment,s)},m(s,l){mount_component(e,s,l),t=!0},p(s,l){const c={};l&5105&&(c.$$scope={dirty:l,ctx:s}),!n&&l&8&&(n=!0,c.handle=s[3],add_flush_callback(()=>n=!1)),e.$set(c)},i(s){t||(transition_in(e.$$.fragment,s),t=!0)},o(s){transition_out(e.$$.fragment,s),t=!1},d(s){destroy_component(e,s)}}}function create_if_block_1$5(a){let e,n;return e=new LabelTag({props:{id:"drag-rect-tag",x:a[8],y:a[9],zoomFactor:a[0],tooltip:`${Math.round(Math.abs(a[6]))}px x ${Math.round(Math.abs(a[7]))}px`,color:"#fff"}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r&256&&(o.x=t[8]),r&512&&(o.y=t[9]),r&1&&(o.zoomFactor=t[0]),r&192&&(o.tooltip=`${Math.round(Math.abs(t[6]))}px x ${Math.round(Math.abs(t[7]))}px`),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_default_slot$5(a){let e,n,t,r;e=new Rect({props:{config:{id:"drag-rect",x:a[4],y:a[5],width:a[6],height:a[7],stroke:"hsl(316deg 60% 29.41%)",fill:"#f9f4f773",strokeWidth:INPUTRECT_STROKEWIDTH/a[0],listening:!1}}});let o=a[8]&&a[9]&&create_if_block_1$5(a);return{c(){create_component(e.$$.fragment),n=space(),o&&o.c(),t=empty()},l(s){claim_component(e.$$.fragment,s),n=claim_space(s),o&&o.l(s),t=empty()},m(s,l){mount_component(e,s,l),insert_hydration(s,n,l),o&&o.m(s,l),insert_hydration(s,t,l),r=!0},p(s,l){const c={};l&241&&(c.config={id:"drag-rect",x:s[4],y:s[5],width:s[6],height:s[7],stroke:"hsl(316deg 60% 29.41%)",fill:"#f9f4f773",strokeWidth:INPUTRECT_STROKEWIDTH/s[0],listening:!1}),e.$set(c),s[8]&&s[9]?o?(o.p(s,l),l&768&&transition_in(o,1)):(o=create_if_block_1$5(s),o.c(),transition_in(o,1),o.m(t.parentNode,t)):o&&(group_outros(),transition_out(o,1,1,()=>{o=null}),check_outros())},i(s){r||(transition_in(e.$$.fragment,s),transition_in(o),r=!0)},o(s){transition_out(e.$$.fragment,s),transition_out(o),r=!1},d(s){s&&(detach(n),detach(t)),destroy_component(e,s),o&&o.d(s)}}}function create_fragment$e(a){let e,n,t=a[1].viewId===a[2]&&create_if_block$7(a);return{c(){t&&t.c(),e=empty()},l(r){t&&t.l(r),e=empty()},m(r,o){t&&t.m(r,o),insert_hydration(r,e,o),n=!0},p(r,[o]){r[1].viewId===r[2]?t?(t.p(r,o),o&6&&transition_in(t,1)):(t=create_if_block$7(r),t.c(),transition_in(t,1),t.m(e.parentNode,e)):t&&(group_outros(),transition_out(t,1,1,()=>{t=null}),check_outros())},i(r){n||(transition_in(t),n=!0)},o(r){transition_out(t),n=!1},d(r){r&&detach(e),t&&t.d(r)}}}function instance$c(a,e,n){let{zoomFactor:t}=e,{newShape:r}=e,{stage:o}=e,{viewId:s}=e,l,c,f,h,u,i,d;function p(_){l=_,n(3,l)}return a.$$set=_=>{"zoomFactor"in _&&n(0,t=_.zoomFactor),"newShape"in _&&n(1,r=_.newShape),"stage"in _&&n(10,o=_.stage),"viewId"in _&&n(2,s=_.viewId)},a.$$.update=()=>{if(a.$$.dirty&1038&&r.status==="creating"){const _=l==null?void 0:l.findOne("#drag-rect");if(_){const m=o.findOne(`#${s}`),g=_.getClientRect({skipTransform:!1,skipShadow:!0,skipStroke:!0,relativeTo:m});n(4,c=r.x),n(5,f=r.y),n(6,h=r.width),n(7,u=r.height),n(8,i=g==null?void 0:g.x),n(9,d=g==null?void 0:g.y)}}},[t,r,s,l,c,f,h,u,i,d,o,p]}class CreateRectangle extends SvelteComponent{constructor(e){super(),init(this,e,instance$c,create_fragment$e,safe_not_equal,{zoomFactor:0,newShape:1,stage:10,viewId:2})}}function get_each_context$4(a,e,n){const t=a.slice();return t[76]=e[n][0],t[77]=e[n][1],t}function get_each_context_1(a,e,n){const t=a.slice();return t[80]=e[n],t}function get_each_context_2(a,e,n){const t=a.slice();return t[83]=e[n],t}function get_each_context_3(a,e,n){const t=a.slice();return t[86]=e[n],t}function create_each_block_3(a){let e,n;function t(...s){return a[29](a[76],...s)}function r(){return a[30](a[76])}function o(){return a[31](a[76])}return e=new Image$1({props:{config:{image:a[86],id:`image-${a[76]}`,zIndex:1}}}),e.$on("pointerdown",t),e.$on("pointerup",r),e.$on("dblclick",o),{c(){create_component(e.$$.fragment)},l(s){claim_component(e.$$.fragment,s)},m(s,l){mount_component(e,s,l),n=!0},p(s,l){a=s;const c={};l[0]&32&&(c.config={image:a[86],id:`image-${a[76]}`,zIndex:1}),e.$set(c)},i(s){n||(transition_in(e.$$.fragment,s),n=!0)},o(s){transition_out(e.$$.fragment,s),n=!1},d(s){destroy_component(e,s)}}}function create_if_block_3$1(a){let e,n;return e=new CreateRectangle({props:{zoomFactor:a[11][a[76]],newShape:a[1],stage:a[6],viewId:a[76]}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r[0]&2080&&(o.zoomFactor=t[11][t[76]]),r[0]&2&&(o.newShape=t[1]),r[0]&64&&(o.stage=t[6]),r[0]&32&&(o.viewId=t[76]),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_if_block_2$2(a){let e=a[83].id,n,t,r=create_key_block_1(a);return{c(){r.c(),n=empty()},l(o){r.l(o),n=empty()},m(o,s){r.m(o,s),insert_hydration(o,n,s),t=!0},p(o,s){s[0]&1&&safe_not_equal(e,e=o[83].id)?(group_outros(),transition_out(r,1,1,noop),check_outros(),r=create_key_block_1(o),r.c(),transition_in(r,1),r.m(n.parentNode,n)):r.p(o,s)},i(o){t||(transition_in(r),t=!0)},o(o){transition_out(r),t=!1},d(o){o&&detach(n),r.d(o)}}}function create_key_block_1(a){let e,n,t;function r(s){a[32](s)}let o={bbox:a[83],colorScale:a[8],zoomFactor:a[11][a[76]],stage:a[6],viewId:a[76],selectedTool:a[4]};return a[1]!==void 0&&(o.newShape=a[1]),e=new Rectangle({props:o}),binding_callbacks.push(()=>bind(e,"newShape",r)),{c(){create_component(e.$$.fragment)},l(s){claim_component(e.$$.fragment,s)},m(s,l){mount_component(e,s,l),t=!0},p(s,l){const c={};l[0]&1&&(c.bbox=s[83]),l[0]&256&&(c.colorScale=s[8]),l[0]&2080&&(c.zoomFactor=s[11][s[76]]),l[0]&64&&(c.stage=s[6]),l[0]&32&&(c.viewId=s[76]),l[0]&16&&(c.selectedTool=s[4]),!n&&l[0]&2&&(n=!0,c.newShape=s[1],add_flush_callback(()=>n=!1)),e.$set(c)},i(s){t||(transition_in(e.$$.fragment,s),t=!0)},o(s){transition_out(e.$$.fragment,s),t=!1},d(s){destroy_component(e,s)}}}function create_each_block_2(a){let e,n,t=a[83].viewId===a[76]&&create_if_block_2$2(a);return{c(){t&&t.c(),e=empty()},l(r){t&&t.l(r),e=empty()},m(r,o){t&&t.m(r,o),insert_hydration(r,e,o),n=!0},p(r,o){r[83].viewId===r[76]?t?(t.p(r,o),o[0]&33&&transition_in(t,1)):(t=create_if_block_2$2(r),t.c(),transition_in(t,1),t.m(e.parentNode,e)):t&&(group_outros(),transition_out(t,1,1,()=>{t=null}),check_outros())},i(r){n||(transition_in(t),n=!0)},o(r){transition_out(t),n=!1},d(r){r&&detach(e),t&&t.d(r)}}}function create_if_block_1$4(a){let e,n,t;function r(s){a[34](s)}let o={viewId:a[76],stage:a[6],currentImage:a[15](a[76]),zoomFactor:a[11],mask:a[80],color:a[8](a[80].id),selectedTool:a[4]};return a[1]!==void 0&&(o.newShape=a[1]),e=new PolygonGroup({props:o}),binding_callbacks.push(()=>bind(e,"newShape",r)),{c(){create_component(e.$$.fragment)},l(s){claim_component(e.$$.fragment,s)},m(s,l){mount_component(e,s,l),t=!0},p(s,l){const c={};l[0]&32&&(c.viewId=s[76]),l[0]&64&&(c.stage=s[6]),l[0]&32&&(c.currentImage=s[15](s[76])),l[0]&2048&&(c.zoomFactor=s[11]),l[0]&4&&(c.mask=s[80]),l[0]&260&&(c.color=s[8](s[80].id)),l[0]&16&&(c.selectedTool=s[4]),!n&&l[0]&2&&(n=!0,c.newShape=s[1],add_flush_callback(()=>n=!1)),e.$set(c)},i(s){t||(transition_in(e.$$.fragment,s),t=!0)},o(s){transition_out(e.$$.fragment,s),t=!1},d(s){destroy_component(e,s)}}}function create_key_block$1(a){let e,n,t=a[80].viewId===a[76]&&create_if_block_1$4(a);return{c(){t&&t.c(),e=empty()},l(r){t&&t.l(r),e=empty()},m(r,o){t&&t.m(r,o),insert_hydration(r,e,o),n=!0},p(r,o){r[80].viewId===r[76]?t?(t.p(r,o),o[0]&36&&transition_in(t,1)):(t=create_if_block_1$4(r),t.c(),transition_in(t,1),t.m(e.parentNode,e)):t&&(group_outros(),transition_out(t,1,1,()=>{t=null}),check_outros())},i(r){n||(transition_in(t),n=!0)},o(r){transition_out(t),n=!1},d(r){r&&detach(e),t&&t.d(r)}}}function create_each_block_1(a){let e=a[80].id,n,t,r=create_key_block$1(a);return{c(){r.c(),n=empty()},l(o){r.l(o),n=empty()},m(o,s){r.m(o,s),insert_hydration(o,n,s),t=!0},p(o,s){s[0]&4&&safe_not_equal(e,e=o[80].id)?(group_outros(),transition_out(r,1,1,noop),check_outros(),r=create_key_block$1(o),r.c(),transition_in(r,1),r.m(n.parentNode,n)):r.p(o,s)},i(o){t||(transition_in(r),t=!0)},o(o){transition_out(r),t=!1},d(o){o&&detach(n),r.d(o)}}}function create_default_slot_1$3(a){let e,n,t,r,o,s,l,c,f,h,u,i,d,p,_,m,g=ensure_array_like(a[77]),b=[];for(let k=0;k<g.length;k+=1)b[k]=create_each_block_3(get_each_context_3(a,g,k));const v=k=>transition_out(b[k],1,1,()=>{b[k]=null});n=new Group({props:{config:{id:"currentAnnotation"}}}),r=new Group({props:{config:{id:"masks"}}}),s=new Group({props:{config:{id:"bboxes"}}}),c=new Group({props:{config:{id:"input"}}});let T=(a[1].status==="creating"&&a[1].type==="rectangle"||a[1].status==="saving"&&a[1].type==="rectangle")&&create_if_block_3$1(a),y=ensure_array_like(a[0]),w=[];for(let k=0;k<y.length;k+=1)w[k]=create_each_block_2(get_each_context_2(a,y,k));const S=k=>transition_out(w[k],1,1,()=>{w[k]=null});function O(k){a[33](k)}let P={viewId:a[76],stage:a[6],currentImage:a[15](a[76]),zoomFactor:a[11],selectedItemId:a[3]};a[1]!==void 0&&(P.newShape=a[1]),i=new CreatePolygon({props:P}),binding_callbacks.push(()=>bind(i,"newShape",O));let E=ensure_array_like(a[2]),A=[];for(let k=0;k<E.length;k+=1)A[k]=create_each_block_1(get_each_context_1(a,E,k));const $=k=>transition_out(A[k],1,1,()=>{A[k]=null});return{c(){for(let k=0;k<b.length;k+=1)b[k].c();e=space(),create_component(n.$$.fragment),t=space(),create_component(r.$$.fragment),o=space(),create_component(s.$$.fragment),l=space(),create_component(c.$$.fragment),f=space(),T&&T.c(),h=space();for(let k=0;k<w.length;k+=1)w[k].c();u=space(),create_component(i.$$.fragment),p=space();for(let k=0;k<A.length;k+=1)A[k].c();_=empty()},l(k){for(let D=0;D<b.length;D+=1)b[D].l(k);e=claim_space(k),claim_component(n.$$.fragment,k),t=claim_space(k),claim_component(r.$$.fragment,k),o=claim_space(k),claim_component(s.$$.fragment,k),l=claim_space(k),claim_component(c.$$.fragment,k),f=claim_space(k),T&&T.l(k),h=claim_space(k);for(let D=0;D<w.length;D+=1)w[D].l(k);u=claim_space(k),claim_component(i.$$.fragment,k),p=claim_space(k);for(let D=0;D<A.length;D+=1)A[D].l(k);_=empty()},m(k,D){for(let I=0;I<b.length;I+=1)b[I]&&b[I].m(k,D);insert_hydration(k,e,D),mount_component(n,k,D),insert_hydration(k,t,D),mount_component(r,k,D),insert_hydration(k,o,D),mount_component(s,k,D),insert_hydration(k,l,D),mount_component(c,k,D),insert_hydration(k,f,D),T&&T.m(k,D),insert_hydration(k,h,D);for(let I=0;I<w.length;I+=1)w[I]&&w[I].m(k,D);insert_hydration(k,u,D),mount_component(i,k,D),insert_hydration(k,p,D);for(let I=0;I<A.length;I+=1)A[I]&&A[I].m(k,D);insert_hydration(k,_,D),m=!0},p(k,D){if(D[0]&3670048){g=ensure_array_like(k[77]);let C;for(C=0;C<g.length;C+=1){const L=get_each_context_3(k,g,C);b[C]?(b[C].p(L,D),transition_in(b[C],1)):(b[C]=create_each_block_3(L),b[C].c(),transition_in(b[C],1),b[C].m(e.parentNode,e))}for(group_outros(),C=g.length;C<b.length;C+=1)v(C);check_outros()}if(k[1].status==="creating"&&k[1].type==="rectangle"||k[1].status==="saving"&&k[1].type==="rectangle"?T?(T.p(k,D),D[0]&2&&transition_in(T,1)):(T=create_if_block_3$1(k),T.c(),transition_in(T,1),T.m(h.parentNode,h)):T&&(group_outros(),transition_out(T,1,1,()=>{T=null}),check_outros()),D[0]&2419){y=ensure_array_like(k[0]);let C;for(C=0;C<y.length;C+=1){const L=get_each_context_2(k,y,C);w[C]?(w[C].p(L,D),transition_in(w[C],1)):(w[C]=create_each_block_2(L),w[C].c(),transition_in(w[C],1),w[C].m(u.parentNode,u))}for(group_outros(),C=y.length;C<w.length;C+=1)S(C);check_outros()}const I={};if(D[0]&32&&(I.viewId=k[76]),D[0]&64&&(I.stage=k[6]),D[0]&32&&(I.currentImage=k[15](k[76])),D[0]&2048&&(I.zoomFactor=k[11]),D[0]&8&&(I.selectedItemId=k[3]),!d&&D[0]&2&&(d=!0,I.newShape=k[1],add_flush_callback(()=>d=!1)),i.$set(I),D[0]&35190){E=ensure_array_like(k[2]);let C;for(C=0;C<E.length;C+=1){const L=get_each_context_1(k,E,C);A[C]?(A[C].p(L,D),transition_in(A[C],1)):(A[C]=create_each_block_1(L),A[C].c(),transition_in(A[C],1),A[C].m(_.parentNode,_))}for(group_outros(),C=E.length;C<A.length;C+=1)$(C);check_outros()}},i(k){if(!m){for(let D=0;D<g.length;D+=1)transition_in(b[D]);transition_in(n.$$.fragment,k),transition_in(r.$$.fragment,k),transition_in(s.$$.fragment,k),transition_in(c.$$.fragment,k),transition_in(T);for(let D=0;D<y.length;D+=1)transition_in(w[D]);transition_in(i.$$.fragment,k);for(let D=0;D<E.length;D+=1)transition_in(A[D]);m=!0}},o(k){b=b.filter(Boolean);for(let D=0;D<b.length;D+=1)transition_out(b[D]);transition_out(n.$$.fragment,k),transition_out(r.$$.fragment,k),transition_out(s.$$.fragment,k),transition_out(c.$$.fragment,k),transition_out(T),w=w.filter(Boolean);for(let D=0;D<w.length;D+=1)transition_out(w[D]);transition_out(i.$$.fragment,k),A=A.filter(Boolean);for(let D=0;D<A.length;D+=1)transition_out(A[D]);m=!1},d(k){k&&(detach(e),detach(t),detach(o),detach(l),detach(f),detach(h),detach(u),detach(p),detach(_)),destroy_each(b,k),destroy_component(n,k),destroy_component(r,k),destroy_component(s,k),destroy_component(c,k),T&&T.d(k),destroy_each(w,k),destroy_component(i,k),destroy_each(A,k)}}}function create_each_block$4(a){let e,n;function t(...r){return a[35](a[76],...r)}return e=new Layer({props:{config:{id:a[76]},$$slots:{default:[create_default_slot_1$3]},$$scope:{ctx:a}}}),e.$on("wheel",t),{c(){create_component(e.$$.fragment)},l(r){claim_component(e.$$.fragment,r)},m(r,o){mount_component(e,r,o),n=!0},p(r,o){a=r;const s={};o[0]&32&&(s.config={id:a[76]}),o[0]&2431|o[2]&134217728&&(s.$$scope={dirty:o,ctx:a}),e.$set(s)},i(r){n||(transition_in(e.$$.fragment,r),n=!0)},o(r){transition_out(e.$$.fragment,r),n=!1},d(r){destroy_component(e,r)}}}function create_default_slot$4(a){let e,n,t,r,o=ensure_array_like(Object.entries(a[5])),s=[];for(let h=0;h<o.length;h+=1)s[h]=create_each_block$4(get_each_context$4(a,o,h));const l=h=>transition_out(s[h],1,1,()=>{s[h]=null});function c(h){a[36](h)}let f={config:{name:"tools"}};return a[13]!==void 0&&(f.handle=a[13]),n=new Layer({props:f}),binding_callbacks.push(()=>bind(n,"handle",c)),{c(){for(let h=0;h<s.length;h+=1)s[h].c();e=space(),create_component(n.$$.fragment)},l(h){for(let u=0;u<s.length;u+=1)s[u].l(h);e=claim_space(h),claim_component(n.$$.fragment,h)},m(h,u){for(let i=0;i<s.length;i+=1)s[i]&&s[i].m(h,u);insert_hydration(h,e,u),mount_component(n,h,u),r=!0},p(h,u){if(u[0]&7899519){o=ensure_array_like(Object.entries(h[5]));let d;for(d=0;d<o.length;d+=1){const p=get_each_context$4(h,o,d);s[d]?(s[d].p(p,u),transition_in(s[d],1)):(s[d]=create_each_block$4(p),s[d].c(),transition_in(s[d],1),s[d].m(e.parentNode,e))}for(group_outros(),d=o.length;d<s.length;d+=1)l(d);check_outros()}const i={};!t&&u[0]&8192&&(t=!0,i.handle=h[13],add_flush_callback(()=>t=!1)),n.$set(i)},i(h){if(!r){for(let u=0;u<o.length;u+=1)transition_in(s[u]);transition_in(n.$$.fragment,h),r=!0}},o(h){s=s.filter(Boolean);for(let u=0;u<s.length;u+=1)transition_out(s[u]);transition_out(n.$$.fragment,h),r=!1},d(h){h&&detach(e),destroy_each(s,h),destroy_component(n,h)}}}function create_if_block$6(a){let e,n;return e=new WarningModal({props:{message:"No embeddings found for view '"+a[10]+"'.",details:"The embeddings may not have finished loading yet. Please try again."}}),e.$on("confirm",a[40]),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r[0]&1024&&(o.message="No embeddings found for view '"+t[10]+"'."),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_fragment$d(a){let e,n,t,r,o,s,l,c,f,h;function u(_){a[37](_)}function i(_){a[38](_)}let d={$$slots:{default:[create_default_slot$4]},$$scope:{ctx:a}};a[14]!==void 0&&(d.config=a[14]),a[6]!==void 0&&(d.handle=a[6]),n=new Stage({props:d}),binding_callbacks.push(()=>bind(n,"config",u)),binding_callbacks.push(()=>bind(n,"handle",i)),n.$on("mousemove",a[16]),n.$on("mouseenter",a[17]),n.$on("mouseleave",a[18]);let p=a[9]&&create_if_block$6(a);return{c(){e=element("div"),create_component(n.$$.fragment),s=space(),p&&p.c(),l=empty(),this.h()},l(_){e=claim_element(_,"DIV",{class:!0});var m=children(e);claim_component(n.$$.fragment,m),m.forEach(detach),s=claim_space(_),p&&p.l(_),l=empty(),this.h()},h(){attr(e,"class",o=cn("flex h-full bg-slate-800 transition-opacity duration-300 delay-100",{"opacity-0":!a[7]}))},m(_,m){insert_hydration(_,e,m),mount_component(n,e,null),a[39](e),insert_hydration(_,s,m),p&&p.m(_,m),insert_hydration(_,l,m),c=!0,f||(h=listen(window,"keydown",a[23]),f=!0)},p(_,m){const g={};m[0]&10623|m[2]&134217728&&(g.$$scope={dirty:m,ctx:_}),!t&&m[0]&16384&&(t=!0,g.config=_[14],add_flush_callback(()=>t=!1)),!r&&m[0]&64&&(r=!0,g.handle=_[6],add_flush_callback(()=>r=!1)),n.$set(g),(!c||m[0]&128&&o!==(o=cn("flex h-full bg-slate-800 transition-opacity duration-300 delay-100",{"opacity-0":!_[7]})))&&attr(e,"class",o),_[9]?p?(p.p(_,m),m[0]&512&&transition_in(p,1)):(p=create_if_block$6(_),p.c(),transition_in(p,1),p.m(l.parentNode,l)):p&&(group_outros(),transition_out(p,1,1,()=>{p=null}),check_outros())},i(_){c||(transition_in(n.$$.fragment,_),transition_in(p),c=!0)},o(_){transition_out(n.$$.fragment,_),transition_out(p),c=!1},d(_){_&&(detach(e),detach(s),detach(l)),destroy_component(n),a[39](null),p&&p.d(_),f=!1,h()}}}function zoom(a,e,n){const r=a.findOne(`#${n}`),o=r.scaleX(),s=a.getRelativePointerPosition(),l={x:(s.x-r.x())/o,y:(s.y-r.y())/o},c=e>0?o*1.05:o/1.05,f={x:s.x-l.x*c,y:s.y-l.y*c};return r.scale({x:c,y:c}),r.position(f),c}function instance$b(a,e,n){let{selectedItemId:t}=e,{colorRange:r=["0","10"]}=e,{masks:o}=e,{bboxes:s}=e,{embeddings:l={}}=e,{currentAnn:c=null}=e,{selectedTool:f}=e,{newShape:h}=e,{imagesPerView:u}=e,i=!1,d,p=!1,_="",m,g,b={},v,T,y,w,S=null,O=new Konva.Transformer({id:"transformer",rotateEnabled:!1}),P={width:1024,height:780,name:"konva",id:"stage"},E={rows:0,cols:0},A;const $=new ResizeObserver(F=>{for(const U of F)if(U.target===T){let X,re;if(U.contentBoxSize){const oe=U.contentBoxSize instanceof ResizeObserverSize?U.contentBoxSize:U.contentBoxSize[0];X=oe.inlineSize,re=oe.blockSize}else X=U.contentRect.width,re=U.contentRect.height;y.width(X),y.height(re),y.batchDraw()}});onMount(()=>{D(),$.observe(T)}),onDestroy(()=>{$e()}),afterUpdate(()=>{A!==t&&D(),f?J():y.container().style.cursor="default",c&&c.validated&&G();for(const F of Object.keys(u)){const U=y.findOne(`#${F}`);U&&U.add(O)}});const k=F=>u[F][u[F].length-1];function D(){E.cols=Math.ceil(Math.sqrt(Object.keys(u).length)),E.rows=Math.ceil(Object.keys(u).length/E.cols),A&&$e();for(const F of Object.keys(u))n(11,b[F]=1,b),k(F).onload=()=>{I(F),C(F),n(7,i=!0),n(2,o),n(0,s)};A=t}function I(F){const U=y.findOne(`#${F}`);if(U){const X=y.width()/E.cols,re=y.height()/E.rows;let oe=0;for(const Xe of Object.keys(u)){if(Xe===F)break;oe++}const ce={x:oe%E.cols,y:Math.floor(oe/E.cols)},he=k(F),De=re/he.height,H=X/he.width,de=Math.min(H,De);n(11,b[F]=de,b),U.scale({x:de,y:de});const me=(X-he.width*de)/2+ce.x*X,Le=(re-he.height*de)/2+ce.y*re;U.x(me),U.y(Le)}else console.log("Canvas2D.scaleView - Error: Cannot scale")}function C(F){const U=y.findOne(`#${F}`),X=U.findOne("#input");if(!X)return;for(const he of X.children)he instanceof Konva.Circle&&(he.radius(INPUTPOINT_RADIUS/b[F]),he.strokeWidth(INPUTPOINT_STROKEWIDTH/b[F])),he instanceof Konva.Rect&&he.strokeWidth(INPUTRECT_STROKEWIDTH/b[F]);const re=U.findOne("#bboxes");if(!re)return;for(const he of re.children)if(he instanceof Konva.Group)for(const De of he.children)De instanceof Konva.Rect&&De.strokeWidth(BBOX_STROKEWIDTH/b[F]),De instanceof Konva.Label&&De.scale({x:1/b[F],y:1/b[F]});const oe=U.findOne("#masks");for(const he of oe.children)he instanceof Konva.Shape&&he.strokeWidth(MASK_STROKEWIDTH/b[F]);const ce=findOrCreateCurrentMask(F,y);for(const he of ce.children)he instanceof Konva.Shape&&he.strokeWidth(MASK_STROKEWIDTH/b[F])}function L(F){let U;return F.getAncestors().forEach(X=>{X instanceof Konva.Layer&&(U=X.id())}),U}async function K(F){const U=ge(F),X=Ce(F),re={image:k(F),embedding:F in l?l[F]:null,points:U,box:X};if(f.postProcessor==null)$e();else if(l[F]==null)n(9,p=!0),n(10,_=F),$e();else{const oe=await f.postProcessor.segmentImage(re);if(oe){n(1,h={masksImageSVG:oe.masksImageSVG,rle:oe.rle,type:"mask",viewId:F,itemId:t,imageWidth:k(F).width,imageHeight:k(F).height,status:"saving"});const ce=findOrCreateCurrentMask(F,y),De=y.findOne(`#${F}`).findOne(`#image-${F}`);ce.removeChildren(),n(24,c={id:nanoid(10),viewId:F,label:"",catId:-1,output:oe,input_points:U,input_box:X,validated:!1});const H={id:c.id,viewId:F,svg:c.output.masksImageSVG,rle:c.output.rle,catId:c.catId,visible:!0,opacity:1};addMask(H,"#008000",ce,De,F,y,b)}}}function G(){if(c.validated){const F=findOrCreateCurrentMask(c.viewId,y);F&&F.destroyChildren(),S&&pe(S),Y(c.viewId),n(24,c=null)}}function J(){switch(w&&w.moveToTop(),f.type){case"POINT_SELECTION":ae(f);break;case"RECTANGLE":ke(f);break;case"DELETE":$e(),Ve(f);break;case"PAN":ee(f);break;case"CLASSIFICATION":ie(f);break}}function Y(F){const U=y==null?void 0:y.findOne(`#${F}`);U&&U.findOne("#input").destroyChildren()}function te(F){if((h==null?void 0:h.status)==="saving")return;const X=y.findOne(`#${F}`).getRelativePointerPosition(),re=Math.round(X.x),oe=Math.round(X.y),ce=h.status==="creating"&&h.type==="mask"?h.points:[];n(1,h={status:"creating",type:"mask",points:[...ce,{x:re,y:oe,id:ce.length||0}],viewId:F})}function ee(F){if(w){const U=y.findOne(`#${POINT_SELECTION}`);U&&U.destroy();const X=y.findOne("#crossline");X&&X.destroy(),S||(y.container().style.cursor=F.cursor),be(!1)}}function ie(F){if(w){const U=y.findOne(`#${POINT_SELECTION}`);U&&U.destroy();const X=y.findOne("#crossline");X&&X.destroy(),S||(y.container().style.cursor=F.cursor),be(!1)}}function ae(F){if(w){const U=w.findOne("#crossline");U&&U.destroy();const X=fe(F.type),re=F.label===1?"green":"red";X.stroke(re),S||(y.container().style.cursor=F.cursor),be(!0)}}function ue(F){const U=fe(f.type),X=y.scaleX(),re=Math.max(1,1/X);U.scaleX(re),U.scaleY(re),U.x(F.x+1),U.y(F.y+1)}function fe(F,U=null){let X=y.findOne(`#${F}`);if(!X){let re=1;U&&(re=b[U]),X=new Konva.Circle({id:F,x:0,y:0,radius:INPUTPOINT_RADIUS/re,fill:"white",strokeWidth:INPUTPOINT_STROKEWIDTH/re,visible:!1,listening:!1,opacity:.5}),w.add(X)}return X}function ge(F){const U=[],re=y.findOne(`#${F}`).findOne("#input");for(const oe of re.children)if(oe instanceof Konva.Circle){const ce={x:oe.x(),y:oe.y(),label:parseInt(oe.name())};U.push(ce)}return U}function be(F){const U=y.find("#input");for(const X of U)for(const re of X.children)re instanceof Konva.Circle&&re.listening(F)}function xe(){y.container().style.cursor="grab"}function ve(F,U){y.container().style.cursor="grabbing";const oe=y.findOne(`#${U}`).findOne(`#image-${U}`).getSize();F.x()<0?F.x(0):F.x()>oe.width&&F.x(oe.width),F.y()<0?F.y(0):F.y()>oe.height&&F.y(oe.height),clearTimeout(v),v=setTimeout(()=>K(U),50)}function Te(F,U){fe(f.type,U).hide(),F.radius(1.5*INPUTPOINT_RADIUS/b[U]),S=F,y.container().style.cursor="grab"}function pe(F,U=null){fe(f.type,U).show(),U||(U=L(F)),F.radius(INPUTPOINT_RADIUS/b[U]),S=null,y.container().style.cursor=f.cursor,y.batchDraw()}function ke(F){if(w){const U=y.findOne(`#${POINT_SELECTION}`);U&&U.destroy(),S||(y.container().style.cursor=F.cursor),be(!0)}}function Pe(F){const U=y.scaleX(),X=Math.max(1,1/U),[re,oe]=Ie(),ce=y.height();re.scaleY(X),re.points([F.x,0,F.x,ce]);const he=y.width();oe.scaleX(X),oe.points([0,F.y,he,F.y])}function Ie(){const F=y.height(),U=y.width();let X=w.findOne("#crossline"),re,oe;return X?(re=X.findOne("#xline"),oe=X.findOne("#yline")):(X=new Konva.Group({id:"crossline"}),re=new Konva.Line({id:"xline",points:[0,0,0,F],stroke:"white",strokeWidth:1,opacity:.75,dash:[5,1]}),oe=new Konva.Line({id:"yline",points:[0,0,U,0],stroke:"white",strokeWidth:1,opacity:.75,dash:[5,1]}),X.add(re),X.add(oe),w.add(X)),[re,oe]}function Ce(F){let U=null;const re=y.findOne(`#${F}`).findOne("#drag-rect");if(re){const oe=re.size(),ce=re.position();U={x:ce.x,y:ce.y,width:oe.width,height:oe.height}}return U}function Ne(F){if((f==null?void 0:f.type)==="RECTANGLE"){const X=y.findOne(`#${F}`).getRelativePointerPosition(),re=h.status==="creating"&&h.type==="rectangle"?h.x:X.x,oe=h.status==="creating"&&h.type==="rectangle"?h.y:X.y;n(1,h={status:"creating",type:"rectangle",x:re,y:oe,width:X.x-re,height:X.y-oe,viewId:F})}}async function Ae(F){if((f==null?void 0:f.type)=="RECTANGLE"){const U=y.findOne(`#${F}`),X=y.findOne("#drag-rect");if(X){const{width:re,height:oe}=X.size();if(re==0||oe==0)n(1,h={status:"none"});else{if(!f.isSmart){const ce=X.getClientRect({skipTransform:!1,skipShadow:!0,skipStroke:!0,relativeTo:U});n(1,h={status:"saving",attrs:{x:ce.x,y:ce.y,width:ce.width,height:ce.height},type:"rectangle",viewId:F,itemId:t,imageWidth:k(F).width,imageHeight:k(F).height})}f.isSmart&&await K(F)}U.off("pointermove"),U.off("pointerup")}f.isSmart&&X.destroy()}}function Ve(F){if(w){const U=y.findOne(`#${POINT_SELECTION}`);U&&U.destroy();const X=y.findOne("#crossline");X&&X.destroy(),S||(y.container().style.cursor=F.cursor),be(!1)}}function $e(){if(!y)return;for(const X of Object.keys(u))Y(X),clearCurrentAnn(X,y,f);f&&(y.container().style.cursor=f.cursor);const F=y.findOne(`#${POINT_SELECTION}`);F&&F.destroy();const U=w==null?void 0:w.findOne("#crossline");U&&U.destroy(),n(24,c=null)}function Oe(){const F=y.getRelativePointerPosition();(f==null?void 0:f.type)==="POINT_SELECTION"&&ue(F),(f==null?void 0:f.type)==="RECTANGLE"&&Pe(F)}function Fe(){for(const F of w.children)F.show()}function We(){for(const F of w.children)F.hide()}function Qe(F){const U=y.findOne(`#${F}`);U.draggable(!1),U.off("dragend dragmove")}function je(F){const U=y.findOne(`#${F}`);if(U.draggable(!1),U.off("dragend dragmove"),(f==null?void 0:f.type)==="POLYGON"&&te(F),S){const X=U.getRelativePointerPosition(),re=S.position();(X.x!==re.x||X.y!==re.y)&&pe(S,F)}}function Be(F){y.findOne(`#${F}`).moveToTop(),w.moveToTop()}async function ze(F,U){const X=y.findOne(`#${U}`);if((h.status==="none"||h.status=="editing"&&h.type=="none")&&n(1,h={status:"editing",type:"none",shapeId:null,highlighted:"all"}),(f==null?void 0:f.type)=="PAN"||F.button==1)X.draggable(!0),X.on("dragmove",Oe),X.on("dragend",()=>Qe(U));else if((f==null?void 0:f.type)=="POINT_SELECTION"){const re=X.getRelativePointerPosition(),oe=new Konva.Circle({name:`${f.label}`,x:re.x,y:re.y,radius:INPUTPOINT_RADIUS/b[U],stroke:"white",fill:f.label===1?"green":"red",strokeWidth:INPUTPOINT_STROKEWIDTH/b[U],visible:!0,listening:!0,opacity:.75,draggable:!0});oe.on("pointerenter",he=>Te(he.target,U)),oe.on("pointerout",he=>pe(he.target,U)),oe.on("dragmove",he=>void ve(he.target,U)),oe.on("dragend",()=>xe()),X.findOne("#input").add(oe),Te(oe,U),await K(U)}else(f==null?void 0:f.type)=="RECTANGLE"&&(X.on("pointermove",()=>Ne(U)),X.on("pointerup",()=>void Ae(U)))}function He(F,U){F.preventDefault();let X=F.deltaY<0?1:-1;F.ctrlKey&&(X=-X),n(11,b[U]=zoom(y,X,U),b),C(U),S&&Te(S,U)}async function et(F){var U,X;if(F.key=="Delete"&&S!=null){const re=L(S),oe=S;pe(S,re),oe.destroy(),y.findOne(`#${re}`).findOne("#input").children.length>0?await K(re):clearCurrentAnn(re,y,f)}if(F.key=="i"){console.log("Canvas2D - Infos"),console.log("masks",o),console.log("bboxes",s),console.log("currentAnn",c),console.log("stage",y);for(const re of Object.keys(u)){const oe=y.findOne(`#${re}`),ce=oe.findOne("#masks"),he=oe.findOne("#bboxes");console.log("masks Konva group:",ce),console.log("masks children length:",(U=ce.children)==null?void 0:U.length),console.log("bboxes Konva group:",he),console.log("bboxes children length:",(X=he.children)==null?void 0:X.length)}}}const qe=(F,U)=>ze(U.detail.evt,F),Ue=F=>je(F),Ke=F=>Be(F);function Ze(F){h=F,n(1,h)}function le(F){h=F,n(1,h)}function Ge(F){h=F,n(1,h)}const Ye=(F,U)=>He(U.detail.evt,F);function R(F){w=F,n(13,w)}function j(F){P=F,n(14,P)}function B(F){y=F,n(6,y)}function q(F){binding_callbacks[F?"unshift":"push"](()=>{T=F,n(12,T)})}const Q=()=>n(9,p=!1);return a.$$set=F=>{"selectedItemId"in F&&n(3,t=F.selectedItemId),"colorRange"in F&&n(25,r=F.colorRange),"masks"in F&&n(2,o=F.masks),"bboxes"in F&&n(0,s=F.bboxes),"embeddings"in F&&n(26,l=F.embeddings),"currentAnn"in F&&n(24,c=F.currentAnn),"selectedTool"in F&&n(4,f=F.selectedTool),"newShape"in F&&n(1,h=F.newShape),"imagesPerView"in F&&n(5,u=F.imagesPerView)},a.$$.update=()=>{if(a.$$.dirty[0]&268435472&&((!(g!=null&&g.isSmart)||!(f!=null&&f.isSmart))&&$e(),n(28,g=f)),a.$$.dirty[0]&2&&h.status==="none"&&h.shouldReset&&$e(),a.$$.dirty[0]&33554432&&n(8,d=ordinalColorScale(r)),a.$$.dirty[0]&134217793){if(y&&m!==(s==null?void 0:s.length)){const F=y==null?void 0:y.findOne("#drag-rect");F&&F.destroy()}n(27,m=s.length)}},[s,h,o,t,f,u,y,i,d,p,_,b,T,w,P,k,Oe,Fe,We,je,Be,ze,He,et,c,r,l,m,g,qe,Ue,Ke,Ze,le,Ge,Ye,R,j,B,q,Q]}class Canvas2D extends SvelteComponent{constructor(e){super(),init(this,e,instance$b,create_fragment$d,safe_not_equal,{selectedItemId:3,colorRange:25,masks:2,bboxes:0,embeddings:26,currentAnn:24,selectedTool:4,newShape:1,imagesPerView:5},null,[-1,-1,-1])}}function create_key_block(a){let e,n,t,r,o;function s(h){a[9](h)}function l(h){a[10](h)}function c(h){a[11](h)}let f={imagesPerView:a[5],selectedItemId:a[1].id,colorRange:a[3],bboxes:a[6],masks:a[7],embeddings:a[2]};return a[4]!==void 0&&(f.selectedTool=a[4]),a[0]!==void 0&&(f.currentAnn=a[0]),a[8]!==void 0&&(f.newShape=a[8]),e=new Canvas2D({props:f}),binding_callbacks.push(()=>bind(e,"selectedTool",s)),binding_callbacks.push(()=>bind(e,"currentAnn",l)),binding_callbacks.push(()=>bind(e,"newShape",c)),{c(){create_component(e.$$.fragment)},l(h){claim_component(e.$$.fragment,h)},m(h,u){mount_component(e,h,u),o=!0},p(h,u){const i={};u&32&&(i.imagesPerView=h[5]),u&2&&(i.selectedItemId=h[1].id),u&8&&(i.colorRange=h[3]),u&64&&(i.bboxes=h[6]),u&128&&(i.masks=h[7]),u&4&&(i.embeddings=h[2]),!n&&u&16&&(n=!0,i.selectedTool=h[4],add_flush_callback(()=>n=!1)),!t&&u&1&&(t=!0,i.currentAnn=h[0],add_flush_callback(()=>t=!1)),!r&&u&256&&(r=!0,i.newShape=h[8],add_flush_callback(()=>r=!1)),e.$set(i)},i(h){o||(transition_in(e.$$.fragment,h),o=!0)},o(h){transition_out(e.$$.fragment,h),o=!1},d(h){destroy_component(e,h)}}}function create_fragment$c(a){let e=a[1].id,n,t,r=create_key_block(a);return{c(){r.c(),n=empty()},l(o){r.l(o),n=empty()},m(o,s){r.m(o,s),insert_hydration(o,n,s),t=!0},p(o,[s]){s&2&&safe_not_equal(e,e=o[1].id)?(group_outros(),transition_out(r,1,1,noop),check_outros(),r=create_key_block(o),r.c(),transition_in(r,1),r.m(n.parentNode,n)):r.p(o,s)},i(o){t||(transition_in(r),t=!0)},o(o){transition_out(r),t=!1},d(o){o&&detach(n),r.d(o)}}}function instance$a(a,e,n){let t,r,o,s;component_subscribe(a,selectedTool,_=>n(4,t=_)),component_subscribe(a,itemBboxes,_=>n(6,r=_)),component_subscribe(a,itemMasks,_=>n(7,o=_)),component_subscribe(a,newShape,_=>n(8,s=_));let{selectedItem:l}=e,{embeddings:c}=e,{currentAnn:f=null}=e,{colorRange:h}=e,u={};function i(_){t=_,selectedTool.set(t)}function d(_){f=_,n(0,f)}function p(_){s=_,newShape.set(s)}return a.$$set=_=>{"selectedItem"in _&&n(1,l=_.selectedItem),"embeddings"in _&&n(2,c=_.embeddings),"currentAnn"in _&&n(0,f=_.currentAnn),"colorRange"in _&&n(3,h=_.colorRange)},a.$$.update=()=>{a.$$.dirty&2&&l.views&&n(5,u=Object.entries(l.views).reduce((_,[m,g])=>{const b=new Image;return b.src=`/${g.uri}`,_[m]=[b],_},{})),a.$$.dirty&16&&selectedTool.set(t)},[f,l,c,h,t,u,r,o,s,i,d,p]}class ImageViewer extends SvelteComponent{constructor(e){super(),init(this,e,instance$a,create_fragment$c,safe_not_equal,{selectedItem:1,embeddings:2,currentAnn:0,colorRange:3})}}const getCurrentImageTime=(a,e)=>{const n=a*e,t=Math.floor(n/6e4),r=(n%6e4/1e3).toFixed(0);return`${t}:${Number(r)<10?"0":""}${r}`},getImageIndexFromMouseMove=(a,e,n)=>{var l,c;const t=(l=e.parentElement)==null?void 0:l.getBoundingClientRect();let r=a.clientX-((t==null?void 0:t.left)||0);r<0&&(r=0);const o=((c=e.parentElement)==null?void 0:c.offsetWidth)||r;r>o&&(r=o);const s=Math.floor(r/o*n)-1;return s<0?0:s},linearInterpolation=(a,e)=>{const n=a.find(w=>w.start<=e&&w.end>=e);if(!n)return null;let t=n.keyBoxes.findIndex(w=>w.frameIndex>e);t=t<0?n.keyBoxes.length-1:t;const r=n.keyBoxes[t-1]||n.keyBoxes[0],o=n.keyBoxes[t],[s,l,c,f]=r.coords,[h,u,i,d]=o.coords,p=(h-s)/(o.frameIndex-(r==null?void 0:r.frameIndex)),_=(u-l)/(o.frameIndex-(r==null?void 0:r.frameIndex)),m=(i-c)/(o.frameIndex-(r==null?void 0:r.frameIndex)),g=(d-f)/(o.frameIndex-(r==null?void 0:r.frameIndex)),b=s+p*(e-r.frameIndex),v=l+_*(e-r.frameIndex),T=c+m*(e-r.frameIndex),y=f+g*(e-r.frameIndex);return[b,v,T,y]},deleteKeyBoxFromTracklet=(a,e,n)=>a.map(t=>(n===t.id&&t.datasetItemType==="video"&&(t.track=t.track.map(r=>(r.start<=e.frameIndex&&r.end>=e.frameIndex&&(r.keyBoxes=r.keyBoxes.filter(o=>o.frameIndex!==e.frameIndex),r.start=r.keyBoxes[0].frameIndex,r.end=r.keyBoxes[r.keyBoxes.length-1].frameIndex),r)).filter(r=>r.keyBoxes.length>1)),t)),editKeyBoxInTracklet=(a,e,n)=>a.map(t=>(n.type==="rectangle"&&t.id===n.shapeId&&t.datasetItemType==="video"&&(t.track=t.track.map(r=>(r.start<=e.frameIndex&&r.end>=e.frameIndex&&(r.keyBoxes=r.keyBoxes.map(o=>(o.frameIndex===e.frameIndex&&(o.coords=n.coords,t.displayedBox.coords=n.coords),o))),r))),t)),createNewTracklet=(a,e,n,t)=>{var o;let r=(o=a.find(s=>s.start>e))==null?void 0:o.start;return r=r?r-1:n,{start:e,end:r,keyBoxes:[{...t,frameIndex:e},{...t,frameIndex:r}]}},addKeyBoxToTracklet=(a,e,n)=>a.map(t=>(t.start===e.start&&t.end===e.end&&(t.keyBoxes.push(n),t.keyBoxes.sort((r,o)=>r.frameIndex-o.frameIndex),t.start=t.keyBoxes[0].frameIndex,t.end=t.keyBoxes[t.keyBoxes.length-1].frameIndex),t)),addKeyBox=(a,e,n,t,r)=>a.map(o=>{if(n!==o.id||o.datasetItemType!=="video")return o;const s=o.track.find(l=>l.start<=t&&l.end>=t);if(s)o.track=addKeyBoxToTracklet(o.track,s,e);else{const l=createNewTracklet(o.track,t,r,e);o.track.push(l)}return o.track.sort((l,c)=>l.start-c.start),o}),findNeighbors=(a,e,n,t)=>{var f,h,u,i;const r=a.findIndex(d=>d.start===e.start&&d.end===e.end);if(r<0)return[0,0];const o=a[r-1];let s=(f=e.keyBoxes.find(d=>d.frameIndex<n))==null?void 0:f.frameIndex;!s&&o&&(s=(h=o.keyBoxes[o.keyBoxes.length-1])==null?void 0:h.frameIndex),s=s||0;let l=(u=e.keyBoxes.find(d=>d.frameIndex>n))==null?void 0:u.frameIndex;const c=a[r+1];return!l&&c&&(l=(i=c.keyBoxes[0])==null?void 0:i.frameIndex),l=l||t+1,[s,l]},filterKeyBoxes=(a,e,n)=>a.reduce((t,r,o)=>(o===0&&t.push(e),n(r.frameIndex)&&t.push(r),t.sort((s,l)=>s.frameIndex-l.frameIndex)),[]),splitTrackletInTwo=(a,e,n)=>{const t=a.track[e],r={start:t.start,end:n,keyBoxes:filterKeyBoxes(t.keyBoxes,{...a.displayedBox,frameIndex:n},s=>s<n)},o={start:n+1,end:t.end,keyBoxes:filterKeyBoxes(t.keyBoxes,{...a.displayedBox,frameIndex:n+1},s=>s>n+1)};return[...a.track.slice(0,e),r,o,...a.track.slice(e+1)]};function create_default_slot_4$1(a){let e,n,t;return{c(){e=element("button"),this.h()},l(r){e=claim_element(r,"BUTTON",{class:!0}),children(e).forEach(detach),this.h()},h(){attr(e,"class","h-full w-full")},m(r,o){insert_hydration(r,e,o),n||(t=action_destroyer(a[6].call(null,e)),n=!0)},p:noop,d(r){r&&detach(e),n=!1,t()}}}function create_default_slot_3$2(a){let e;return{c(){e=text("Remove key box")},l(n){e=claim_text(n,"Remove key box")},m(n,t){insert_hydration(n,e,t)},d(n){n&&detach(e)}}}function create_default_slot_2$2(a){let e=a[1]?"Stop editing":"Edit box",n;return{c(){n=text(e)},l(t){n=claim_text(t,e)},m(t,r){insert_hydration(t,n,r)},p(t,r){r&2&&e!==(e=t[1]?"Stop editing":"Edit box")&&set_data(n,e)},d(t){t&&detach(n)}}}function create_default_slot_1$2(a){let e,n,t,r;return e=new Context_menu_item({props:{inset:!0,$$slots:{default:[create_default_slot_3$2]},$$scope:{ctx:a}}}),e.$on("click",a[10]),t=new Context_menu_item({props:{inset:!0,$$slots:{default:[create_default_slot_2$2]},$$scope:{ctx:a}}}),t.$on("click",a[11]),{c(){create_component(e.$$.fragment),n=space(),create_component(t.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(t.$$.fragment,o)},m(o,s){mount_component(e,o,s),insert_hydration(o,n,s),mount_component(t,o,s),r=!0},p(o,s){const l={};s&16384&&(l.$$scope={dirty:s,ctx:o}),e.$set(l);const c={};s&16386&&(c.$$scope={dirty:s,ctx:o}),t.$set(c)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(t.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(t.$$.fragment,o),r=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(t,o)}}}function create_default_slot$3(a){let e,n,t,r;return e=new Trigger({props:{class:cn("w-4 h-4 block bg-white border-2 rounded-full absolute left-[-0.5rem] top-1/2 translate-y-[-50%] translate-x-[-50%]","hover:scale-150",{"bg-primary !border-primary":a[1]}),style:`left: ${a[5](a[0])}%; border-color: ${a[2]}`,$$slots:{default:[create_default_slot_4$1]},$$scope:{ctx:a}}}),t=new Context_menu_content({props:{$$slots:{default:[create_default_slot_1$2]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment),n=space(),create_component(t.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(t.$$.fragment,o)},m(o,s){mount_component(e,o,s),insert_hydration(o,n,s),mount_component(t,o,s),r=!0},p(o,s){const l={};s&2&&(l.class=cn("w-4 h-4 block bg-white border-2 rounded-full absolute left-[-0.5rem] top-1/2 translate-y-[-50%] translate-x-[-50%]","hover:scale-150",{"bg-primary !border-primary":o[1]})),s&5&&(l.style=`left: ${o[5](o[0])}%; border-color: ${o[2]}`),s&16384&&(l.$$scope={dirty:s,ctx:o}),e.$set(l);const c={};s&16395&&(c.$$scope={dirty:s,ctx:o}),t.$set(c)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(t.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(t.$$.fragment,o),r=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(t,o)}}}function create_fragment$b(a){let e,n;return e=new Root({props:{$$slots:{default:[create_default_slot$3]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,[r]){const o={};r&16399&&(o.$$scope={dirty:r,ctx:t}),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function instance$9(a,e,n){let t,r;component_subscribe(a,lastFrameIndex,g=>n(12,t=g)),component_subscribe(a,itemBoxBeingEdited,g=>n(13,r=g));let{objectId:o}=e,{keyBox:s}=e,{isBeingEdited:l}=e,{color:c}=e,{oneFrameInPixel:f}=e,{onEditKeyBoxClick:h}=e,{updateTrackletWidth:u}=e;(r==null?void 0:r.objectId)===o&&(s.frameIndex,r==null||r.frameIndex);const i=g=>{itemObjects.update(b=>deleteKeyBoxFromTracklet(b,g,o))},d=g=>(g.frameIndex>t?t:g.frameIndex)/(t+1)*100,p=g=>{let b=!1,v,T,y;g.addEventListener("mousedown",w=>{b=!0,v=w.clientX,T=s.frameIndex,y=f}),window.addEventListener("mousemove",w=>{if(b&&l){const O=(w.clientX-v)/y,P=T+O;u(Math.round(P),s.frameIndex)}}),window.addEventListener("mouseup",()=>{b=!1})},_=()=>i(s),m=()=>h(s);return a.$$set=g=>{"objectId"in g&&n(7,o=g.objectId),"keyBox"in g&&n(0,s=g.keyBox),"isBeingEdited"in g&&n(1,l=g.isBeingEdited),"color"in g&&n(2,c=g.color),"oneFrameInPixel"in g&&n(8,f=g.oneFrameInPixel),"onEditKeyBoxClick"in g&&n(3,h=g.onEditKeyBoxClick),"updateTrackletWidth"in g&&n(9,u=g.updateTrackletWidth)},[s,l,c,h,i,d,p,o,f,u,_,m]}class TrackletKeyBox extends SvelteComponent{constructor(e){super(),init(this,e,instance$9,create_fragment$b,safe_not_equal,{objectId:7,keyBox:0,isBeingEdited:1,color:2,oneFrameInPixel:8,onEditKeyBoxClick:3,updateTrackletWidth:9})}}function get_each_context$3(a,e,n){const t=a.slice();return t[21]=e[n],t}function create_default_slot_5(a){let e,n,t;return{c(){e=element("button"),this.h()},l(r){e=claim_element(r,"BUTTON",{class:!0}),children(e).forEach(detach),this.h()},h(){attr(e,"class","h-full w-full")},m(r,o){insert_hydration(r,e,o),a[16](e),n||(t=listen(e,"contextmenu",prevent_default(a[15])),n=!0)},p:noop,d(r){r&&detach(e),a[16](null),n=!1,t()}}}function create_default_slot_4(a){let e;return{c(){e=text("Add a point")},l(n){e=claim_text(n,"Add a point")},m(n,t){insert_hydration(n,e,t)},d(n){n&&detach(e)}}}function create_default_slot_3$1(a){let e;return{c(){e=text("Split tracklet")},l(n){e=claim_text(n,"Split tracklet")},m(n,t){insert_hydration(n,e,t)},d(n){n&&detach(e)}}}function create_default_slot_2$1(a){let e;return{c(){e=text("Delete tracklet")},l(n){e=claim_text(n,"Delete tracklet")},m(n,t){insert_hydration(n,e,t)},d(n){n&&detach(e)}}}function create_default_slot_1$1(a){let e,n,t,r,o,s;return e=new Context_menu_item({props:{inset:!0,$$slots:{default:[create_default_slot_4]},$$scope:{ctx:a}}}),e.$on("click",function(){is_function(a[5])&&a[5].apply(this,arguments)}),t=new Context_menu_item({props:{inset:!0,$$slots:{default:[create_default_slot_3$1]},$$scope:{ctx:a}}}),t.$on("click",function(){is_function(a[6])&&a[6].apply(this,arguments)}),o=new Context_menu_item({props:{inset:!0,$$slots:{default:[create_default_slot_2$1]},$$scope:{ctx:a}}}),o.$on("click",function(){is_function(a[7])&&a[7].apply(this,arguments)}),{c(){create_component(e.$$.fragment),n=space(),create_component(t.$$.fragment),r=space(),create_component(o.$$.fragment)},l(l){claim_component(e.$$.fragment,l),n=claim_space(l),claim_component(t.$$.fragment,l),r=claim_space(l),claim_component(o.$$.fragment,l)},m(l,c){mount_component(e,l,c),insert_hydration(l,n,c),mount_component(t,l,c),insert_hydration(l,r,c),mount_component(o,l,c),s=!0},p(l,c){a=l;const f={};c&16777216&&(f.$$scope={dirty:c,ctx:a}),e.$set(f);const h={};c&16777216&&(h.$$scope={dirty:c,ctx:a}),t.$set(h);const u={};c&16777216&&(u.$$scope={dirty:c,ctx:a}),o.$set(u)},i(l){s||(transition_in(e.$$.fragment,l),transition_in(t.$$.fragment,l),transition_in(o.$$.fragment,l),s=!0)},o(l){transition_out(e.$$.fragment,l),transition_out(t.$$.fragment,l),transition_out(o.$$.fragment,l),s=!1},d(l){l&&(detach(n),detach(r)),destroy_component(e,l),destroy_component(t,l),destroy_component(o,l)}}}function create_default_slot$2(a){let e,n,t,r;return e=new Trigger({props:{class:cn("h-4/5 w-full absolute top-1/2 -translate-y-1/2"),style:`left: ${a[10]}%; width: ${a[9]}%; background-color: ${a[2]}`,$$slots:{default:[create_default_slot_5]},$$scope:{ctx:a}}}),t=new Context_menu_content({props:{$$slots:{default:[create_default_slot_1$1]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment),n=space(),create_component(t.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(t.$$.fragment,o)},m(o,s){mount_component(e,o,s),insert_hydration(o,n,s),mount_component(t,o,s),r=!0},p(o,s){const l={};s&1540&&(l.style=`left: ${o[10]}%; width: ${o[9]}%; background-color: ${o[2]}`),s&16777480&&(l.$$scope={dirty:s,ctx:o}),e.$set(l);const c={};s&16777440&&(c.$$scope={dirty:s,ctx:o}),t.$set(c)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(t.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(t.$$.fragment,o),r=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(t,o)}}}function create_each_block$3(a){let e,n;return e=new TrackletKeyBox({props:{keyBox:a[21],color:a[2],isBeingEdited:a[13](a[21]),onEditKeyBoxClick:a[4],objectId:a[1].id,updateTrackletWidth:a[12],oneFrameInPixel:a[11]}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r&1&&(o.keyBox=t[21]),r&4&&(o.color=t[2]),r&1&&(o.isBeingEdited=t[13](t[21])),r&16&&(o.onEditKeyBoxClick=t[4]),r&2&&(o.objectId=t[1].id),r&2048&&(o.oneFrameInPixel=t[11]),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_fragment$a(a){let e,n,t,r;e=new Root({props:{$$slots:{default:[create_default_slot$2]},$$scope:{ctx:a}}});let o=ensure_array_like(a[0].keyBoxes),s=[];for(let c=0;c<o.length;c+=1)s[c]=create_each_block$3(get_each_context$3(a,o,c));const l=c=>transition_out(s[c],1,1,()=>{s[c]=null});return{c(){create_component(e.$$.fragment),n=space();for(let c=0;c<s.length;c+=1)s[c].c();t=empty()},l(c){claim_component(e.$$.fragment,c),n=claim_space(c);for(let f=0;f<s.length;f+=1)s[f].l(c);t=empty()},m(c,f){mount_component(e,c,f),insert_hydration(c,n,f);for(let h=0;h<s.length;h+=1)s[h]&&s[h].m(c,f);insert_hydration(c,t,f),r=!0},p(c,[f]){const h={};if(f&16779244&&(h.$$scope={dirty:f,ctx:c}),e.$set(h),f&14359){o=ensure_array_like(c[0].keyBoxes);let u;for(u=0;u<o.length;u+=1){const i=get_each_context$3(c,o,u);s[u]?(s[u].p(i,f),transition_in(s[u],1)):(s[u]=create_each_block$3(i),s[u].c(),transition_in(s[u],1),s[u].m(t.parentNode,t))}for(group_outros(),u=o.length;u<s.length;u+=1)l(u);check_outros()}},i(c){if(!r){transition_in(e.$$.fragment,c);for(let f=0;f<o.length;f+=1)transition_in(s[f]);r=!0}},o(c){transition_out(e.$$.fragment,c),s=s.filter(Boolean);for(let f=0;f<s.length;f+=1)transition_out(s[f]);r=!1},d(c){c&&(detach(n),detach(t)),destroy_component(e,c),destroy_each(s,c)}}}function instance$8(a,e,n){let t,r,o;component_subscribe(a,itemBoxBeingEdited,O=>n(17,r=O)),component_subscribe(a,lastFrameIndex,O=>n(18,o=O));let{object:s}=e,{color:l}=e,{tracklet:c}=e,{onContextMenu:f}=e,{onEditKeyBoxClick:h}=e,{onAddKeyBoxClick:u}=e,{onSplitTrackletClick:i}=e,{onDeleteTrackletClick:d}=e,{findNeighborKeyBoxes:p}=e;const _=O=>O.start/(o+1)*100,m=O=>((O.end>o?o:O.end)-O.start)/(o+1)*100;let g=m(c),b=_(c),v;const T=(O,P)=>{const[E,A]=p(c,P);O<=E||O>=A||(n(0,c.keyBoxes=c.keyBoxes.map($=>($.frameIndex===P&&($.frameIndex=O,itemBoxBeingEdited.set({...$,objectId:s.id})),$)),c),n(0,c.start=c.keyBoxes[0].frameIndex,c),n(0,c.end=c.keyBoxes[c.keyBoxes.length-1].frameIndex,c))},y=O=>(r==null?void 0:r.objectId)===s.id&&O.frameIndex===(r==null?void 0:r.frameIndex),w=O=>f(O);function S(O){binding_callbacks[O?"unshift":"push"](()=>{v=O,n(8,v)})}return a.$$set=O=>{"object"in O&&n(1,s=O.object),"color"in O&&n(2,l=O.color),"tracklet"in O&&n(0,c=O.tracklet),"onContextMenu"in O&&n(3,f=O.onContextMenu),"onEditKeyBoxClick"in O&&n(4,h=O.onEditKeyBoxClick),"onAddKeyBoxClick"in O&&n(5,u=O.onAddKeyBoxClick),"onSplitTrackletClick"in O&&n(6,i=O.onSplitTrackletClick),"onDeleteTrackletClick"in O&&n(7,d=O.onDeleteTrackletClick),"findNeighborKeyBoxes"in O&&n(14,p=O.findNeighborKeyBoxes)},a.$$.update=()=>{a.$$.dirty&1&&n(9,g=m(c)),a.$$.dirty&1&&n(10,b=_(c)),a.$$.dirty&257&&n(11,t=(v==null?void 0:v.getBoundingClientRect().width)/(c.end-c.start+1))},[c,s,l,f,h,u,i,d,v,g,b,t,T,y,p,w,S]}class ObjectTracklet extends SvelteComponent{constructor(e){super(),init(this,e,instance$8,create_fragment$a,safe_not_equal,{object:1,color:2,tracklet:0,onContextMenu:3,onEditKeyBoxClick:4,onAddKeyBoxClick:5,onSplitTrackletClick:6,onDeleteTrackletClick:7,findNeighborKeyBoxes:14})}}function get_each_context$2(a,e,n){const t=a.slice();return t[21]=e[n],t[23]=n,t}function create_default_slot_3(a){let e,n,t;return{c(){e=element("p"),this.h()},l(r){e=claim_element(r,"P",{class:!0}),children(e).forEach(detach),this.h()},h(){attr(e,"class","h-full w-full")},m(r,o){insert_hydration(r,e,o),n||(t=listen(e,"contextmenu",prevent_default(a[14])),n=!0)},p:noop,d(r){r&&detach(e),n=!1,t()}}}function create_default_slot_2(a){let e;return{c(){e=text("Add a point")},l(n){e=claim_text(n,"Add a point")},m(n,t){insert_hydration(n,e,t)},d(n){n&&detach(e)}}}function create_default_slot_1(a){let e,n;return e=new Context_menu_item({props:{inset:!0,$$slots:{default:[create_default_slot_2]},$$scope:{ctx:a}}}),e.$on("click",a[9]),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r&16777216&&(o.$$scope={dirty:r,ctx:t}),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_default_slot$1(a){let e,n,t,r;return e=new Trigger({props:{class:"h-full w-full absolute left-0",style:`width: ${a[6]}%`,$$slots:{default:[create_default_slot_3]},$$scope:{ctx:a}}}),t=new Context_menu_content({props:{$$slots:{default:[create_default_slot_1]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment),n=space(),create_component(t.$$.fragment)},l(o){claim_component(e.$$.fragment,o),n=claim_space(o),claim_component(t.$$.fragment,o)},m(o,s){mount_component(e,o,s),insert_hydration(o,n,s),mount_component(t,o,s),r=!0},p(o,s){const l={};s&64&&(l.style=`width: ${o[6]}%`),s&16777216&&(l.$$scope={dirty:s,ctx:o}),e.$set(l);const c={};s&16777216&&(c.$$scope={dirty:s,ctx:o}),t.$set(c)},i(o){r||(transition_in(e.$$.fragment,o),transition_in(t.$$.fragment,o),r=!0)},o(o){transition_out(e.$$.fragment,o),transition_out(t.$$.fragment,o),r=!1},d(o){o&&detach(n),destroy_component(e,o),destroy_component(t,o)}}}function create_each_block$2(a){let e,n;function t(){return a[15](a[23])}function r(){return a[16](a[23])}return e=new ObjectTracklet({props:{tracklet:a[21],object:a[2],color:a[3](a[2].id),onAddKeyBoxClick:a[9],onContextMenu:a[7],onEditKeyBoxClick:a[8],onSplitTrackletClick:t,onDeleteTrackletClick:r,findNeighborKeyBoxes:a[12]}}),{c(){create_component(e.$$.fragment)},l(o){claim_component(e.$$.fragment,o)},m(o,s){mount_component(e,o,s),n=!0},p(o,s){a=o;const l={};s&4&&(l.tracklet=a[21]),s&4&&(l.object=a[2]),s&12&&(l.color=a[3](a[2].id)),e.$set(l)},i(o){n||(transition_in(e.$$.fragment,o),n=!0)},o(o){transition_out(e.$$.fragment,o),n=!1},d(o){destroy_component(e,o)}}}function create_fragment$9(a){let e,n,t,r,o,s,l,c;o=new Root({props:{$$slots:{default:[create_default_slot$1]},$$scope:{ctx:a}}});let f=ensure_array_like(a[2].track),h=[];for(let i=0;i<f.length;i+=1)h[i]=create_each_block$2(get_each_context$2(a,f,i));const u=i=>transition_out(h[i],1,1,()=>{h[i]=null});return{c(){e=element("div"),n=element("span"),r=space(),create_component(o.$$.fragment),s=space();for(let i=0;i<h.length;i+=1)h[i].c();this.h()},l(i){e=claim_element(i,"DIV",{class:!0,style:!0});var d=children(e);n=claim_element(d,"SPAN",{class:!0,style:!0}),children(n).forEach(detach),r=claim_space(d),claim_component(o.$$.fragment,d),s=claim_space(d);for(let p=0;p<h.length;p+=1)h[p].l(d);d.forEach(detach),this.h()},h(){attr(n,"class","w-[1px] bg-primary h-full absolute top-0 z-30 pointer-events-none"),attr(n,"style",t=`left: ${a[1]/(a[4]+1)*100}%`),attr(e,"class","flex gap-5 relative h-full my-auto"),attr(e,"style",l=`width: ${a[0][0]}%`)},m(i,d){insert_hydration(i,e,d),append_hydration(e,n),append_hydration(e,r),mount_component(o,e,null),append_hydration(e,s);for(let p=0;p<h.length;p+=1)h[p]&&h[p].m(e,null);a[17](e),c=!0},p(i,[d]){(!c||d&18&&t!==(t=`left: ${i[1]/(i[4]+1)*100}%`))&&attr(n,"style",t);const p={};if(d&16777280&&(p.$$scope={dirty:d,ctx:i}),o.$set(p),d&8076){f=ensure_array_like(i[2].track);let _;for(_=0;_<f.length;_+=1){const m=get_each_context$2(i,f,_);h[_]?(h[_].p(m,d),transition_in(h[_],1)):(h[_]=create_each_block$2(m),h[_].c(),transition_in(h[_],1),h[_].m(e,null))}for(group_outros(),_=f.length;_<h.length;_+=1)u(_);check_outros()}(!c||d&1&&l!==(l=`width: ${i[0][0]}%`))&&attr(e,"style",l)},i(i){if(!c){transition_in(o.$$.fragment,i);for(let d=0;d<f.length;d+=1)transition_in(h[d]);c=!0}},o(i){transition_out(o.$$.fragment,i),h=h.filter(Boolean);for(let d=0;d<h.length;d+=1)transition_out(h[d]);c=!1},d(i){i&&detach(e),destroy_component(o),destroy_each(h,i),a[17](null)}}}function instance$7(a,e,n){let t,r,o;component_subscribe(a,lastFrameIndex,O=>n(4,r=O)),component_subscribe(a,itemBoxBeingEdited,O=>n(19,o=O));let{zoomLevel:s}=e,{currentImageIndex:l}=e,{object:c}=e,{colorScale:f}=e,{onTimeTrackClick:h}=e,u,i;const d=O=>{itemObjects.update(A=>A.map($=>($.highlighted=$.id===c.id?"self":"none",$.displayControl={...$.displayControl,editing:!1},$)));const P=i.getBoundingClientRect(),E=(O.clientX-P.left)/P.width;u=Math.round(E*r),h(u)},p=O=>(o==null?void 0:o.objectId)===c.id&&O.frameIndex===(o==null?void 0:o.frameIndex),_=O=>{const P=p(O);itemBoxBeingEdited.set(P?null:{...O,objectId:c.id}),h(O.frameIndex>r?r:O.frameIndex),itemObjects.update(E=>E.map(A=>(A.highlighted=A.id===c.id?"self":"none",A.highlighted=P?"all":A.highlighted,A.displayControl={...A.displayControl,editing:!P&&A.id===c.id},A)))},m=()=>{const O={...c.displayedBox,frameIndex:u};itemObjects.update(P=>addKeyBox(P,O,c.id,u,r)),_(O)},g=O=>{itemObjects.update(P=>P.map(E=>{if(E.id===c.id&&E.datasetItemType==="video"){const A=splitTrackletInTwo(E,O,u);return{...E,track:A}}return E}))},b=O=>{itemObjects.update(P=>P.map(E=>(E.id===c.id&&E.datasetItemType==="video"&&E.track.splice(O,1),E)))},v=(O,P)=>findNeighbors(c.track,O,P,r),T=O=>d(O),y=O=>g(O),w=O=>b(O);function S(O){binding_callbacks[O?"unshift":"push"](()=>{i=O,n(5,i)})}return a.$$set=O=>{"zoomLevel"in O&&n(0,s=O.zoomLevel),"currentImageIndex"in O&&n(1,l=O.currentImageIndex),"object"in O&&n(2,c=O.object),"colorScale"in O&&n(3,f=O.colorScale),"onTimeTrackClick"in O&&n(13,h=O.onTimeTrackClick)},a.$$.update=()=>{a.$$.dirty&16&&n(6,t=r/(r+1)*100)},[s,l,c,f,r,i,t,d,_,m,g,b,v,h,T,y,w,S]}class ObjectTrack extends SvelteComponent{constructor(e){super(),init(this,e,instance$7,create_fragment$9,safe_not_equal,{zoomLevel:0,currentImageIndex:1,object:2,colorScale:3,onTimeTrackClick:13})}}function get_each_context$1(a,e,n){const t=a.slice();return t[13]=e[n],t}function create_else_block$1(a){let e;return{c(){e=element("span"),this.h()},l(n){e=claim_element(n,"SPAN",{class:!0,style:!0}),children(e).forEach(detach),this.h()},h(){attr(e,"class","absolute text-slate-300 w-[1px] h-1 bg-slate-300 bottom-1/3 pointer-events-none"),attr(e,"style",`left: ${a[13]*100/a[4]*100}%`)},m(n,t){insert_hydration(n,e,t)},p:noop,d(n){n&&detach(e)}}}function create_if_block$5(a){let e,n,t,r=a[13]>0&&create_if_block_1$3(a);return{c(){e=element("span"),n=space(),r&&r.c(),t=empty(),this.h()},l(o){e=claim_element(o,"SPAN",{class:!0,style:!0}),children(e).forEach(detach),n=claim_space(o),r&&r.l(o),t=empty(),this.h()},h(){attr(e,"class","absolute text-slate-300 w-[1px] h-1 bg-slate-500 bottom-1/3 pointer-events-none"),attr(e,"style",`left: ${a[13]*100/a[4]*100}%`)},m(o,s){insert_hydration(o,e,s),insert_hydration(o,n,s),r&&r.m(o,s),insert_hydration(o,t,s)},p(o,s){o[13]>0&&r.p(o,s)},d(o){o&&(detach(e),detach(n),detach(t)),r&&r.d(o)}}}function create_if_block_1$3(a){let e,n=a[13]/10+"",t,r;return{c(){e=element("span"),t=text(n),r=text("s"),this.h()},l(o){e=claim_element(o,"SPAN",{class:!0,style:!0});var s=children(e);t=claim_text(s,n),r=claim_text(s,"s"),s.forEach(detach),this.h()},h(){attr(e,"class","absolute -translate-x-1/2 text-slate-300 bottom-1/3 pointer-events-none font-light text-xs pb-1"),attr(e,"style",`left: ${a[13]*100/a[4]*100}%`)},m(o,s){insert_hydration(o,e,s),append_hydration(e,t),append_hydration(e,r)},p:noop,d(o){o&&detach(e)}}}function create_each_block$1(a){let e;function n(o,s){return o[13]%10===0?create_if_block$5:create_else_block$1}let r=n(a)(a);return{c(){r.c(),e=empty()},l(o){r.l(o),e=empty()},m(o,s){r.m(o,s),insert_hydration(o,e,s)},p(o,s){r.p(o,s)},d(o){o&&detach(e),r.d(o)}}}function create_fragment$8(a){let e,n,t,r,o,s,l,c="",f,h,u,i,d,p,_,m,g,b=ensure_array_like(a[5]),v=[];for(let T=0;T<b.length;T+=1)v[T]=create_each_block$1(get_each_context$1(a,b,T));return{c(){e=element("div"),n=element("span"),t=space(),r=element("button"),o=element("span"),s=space(),l=element("span"),l.innerHTML=c,f=space(),h=element("span"),u=space(),i=element("span"),p=space();for(let T=0;T<v.length;T+=1)v[T].c();this.h()},l(T){e=claim_element(T,"DIV",{class:!0,style:!0,role:!0,tabindex:!0,"aria-valuenow":!0});var y=children(e);n=claim_element(y,"SPAN",{class:!0}),children(n).forEach(detach),t=claim_space(y),r=claim_element(y,"BUTTON",{class:!0,style:!0});var w=children(r);o=claim_element(w,"SPAN",{class:!0}),children(o).forEach(detach),s=claim_space(w),l=claim_element(w,"SPAN",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(l)!=="svelte-8hqanj"&&(l.innerHTML=c),f=claim_space(w),h=claim_element(w,"SPAN",{class:!0}),children(h).forEach(detach),u=claim_space(w),i=claim_element(w,"SPAN",{class:!0}),children(i).forEach(detach),w.forEach(detach),p=claim_space(y);for(let S=0;S<v.length;S+=1)v[S].l(y);y.forEach(detach),this.h()},h(){attr(n,"class","bg-slate-200 w-full h-[1px] absolute top-2/3"),attr(o,"class","block h-[60%] bg-primary w-2 rounded-t"),attr(l,"class","block w-0 h-0 border-l-[4px] border-l-transparent border-t-[8px] border-t-primary border-r-[4px] border-r-transparent"),attr(h,"class","w-[1px] bg-primary absolute ml-1"),attr(i,"class","w-[1px] bg-primary h-5 absolute top-full ml-1"),attr(r,"class","h-8 w-1 absolute bottom-1/3 flex flex-col translate-x-[-4px]"),attr(r,"style",d=`left: ${a[0]*a[2]/a[4]*100}%`),attr(e,"class","py-2 flex w-full h-full justify-between relative cursor-pointer bg-white border-b border-slate-200"),attr(e,"style",_=`width: ${a[3][0]}%`),attr(e,"role","slider"),attr(e,"tabindex","0"),attr(e,"aria-valuenow",a[0])},m(T,y){insert_hydration(T,e,y),append_hydration(e,n),append_hydration(e,t),append_hydration(e,r),append_hydration(r,o),append_hydration(r,s),append_hydration(r,l),append_hydration(r,f),append_hydration(r,h),append_hydration(r,u),append_hydration(r,i),a[10](r),append_hydration(e,p);for(let w=0;w<v.length;w+=1)v[w]&&v[w].m(e,null);m||(g=[action_destroyer(a[6].call(null,r)),listen(e,"click",a[7]),listen(e,"keydown",a[7])],m=!0)},p(T,[y]){if(y&5&&d!==(d=`left: ${T[0]*T[2]/T[4]*100}%`)&&attr(r,"style",d),y&48){b=ensure_array_like(T[5]);let w;for(w=0;w<b.length;w+=1){const S=get_each_context$1(T,b,w);v[w]?v[w].p(S,y):(v[w]=create_each_block$1(S),v[w].c(),v[w].m(e,null))}for(;w<v.length;w+=1)v[w].d(1);v.length=b.length}y&8&&_!==(_=`width: ${T[3][0]}%`)&&attr(e,"style",_),y&1&&attr(e,"aria-valuenow",T[0])},i:noop,o:noop,d(T){T&&detach(e),a[10](null),destroy_each(v,T),m=!1,run_all(g)}}}function instance$6(a,e,n){let t;component_subscribe(a,lastFrameIndex,m=>n(11,t=m));let{updateView:r}=e,{intervalId:o}=e,{videoSpeed:s}=e,{currentImageIndex:l}=e,{cursorElement:c}=e,{zoomLevel:f}=e,h=t+1;const u=h*s;let i=[...Array(Math.floor(u/100)).keys()];const d=m=>{let g=!1;m.addEventListener("mousedown",()=>{g=!0,clearInterval(o)}),window.addEventListener("mousemove",b=>{g&&(n(0,l=getImageIndexFromMouseMove(b,m,h)),r(l))}),window.addEventListener("mouseup",()=>{g=!1})},p=m=>{let g=m.target;m instanceof KeyboardEvent||g.localName==="button"||(clearInterval(o),n(0,l=Math.floor(m.offsetX/g.offsetWidth*h)),r(l))};function _(m){binding_callbacks[m?"unshift":"push"](()=>{c=m,n(1,c)})}return a.$$set=m=>{"updateView"in m&&n(8,r=m.updateView),"intervalId"in m&&n(9,o=m.intervalId),"videoSpeed"in m&&n(2,s=m.videoSpeed),"currentImageIndex"in m&&n(0,l=m.currentImageIndex),"cursorElement"in m&&n(1,c=m.cursorElement),"zoomLevel"in m&&n(3,f=m.zoomLevel)},[l,c,s,f,u,i,d,p,r,o,_]}class TimeTrack extends SvelteComponent{constructor(e){super(),init(this,e,instance$6,create_fragment$8,safe_not_equal,{updateView:8,intervalId:9,videoSpeed:2,currentImageIndex:0,cursorElement:1,zoomLevel:3})}}const get_timeTrack_slot_changes=a=>({}),get_timeTrack_slot_context=a=>({}),get_name_slot_changes=a=>({}),get_name_slot_context=a=>({});function create_fragment$7(a){let e,n,t,r,o,s,l,c,f;const h=a[3].name,u=create_slot(h,a,a[2],get_name_slot_context),i=a[3].timeTrack,d=create_slot(i,a,a[2],get_timeTrack_slot_context);return{c(){e=element("div"),n=element("div"),u&&u.c(),t=space(),r=element("div"),s=space(),l=element("div"),d&&d.c(),this.h()},l(p){e=claim_element(p,"DIV",{class:!0});var _=children(e);n=claim_element(_,"DIV",{class:!0});var m=children(n);u&&u.l(m),m.forEach(detach),t=claim_space(_),r=claim_element(_,"DIV",{class:!0}),children(r).forEach(detach),s=claim_space(_),l=claim_element(_,"DIV",{class:!0});var g=children(l);d&&d.l(g),g.forEach(detach),_.forEach(detach),this.h()},h(){attr(n,"class",cn("grow w-1/3 max-w-[25%] sticky top-0 left-0 bg-white border-r border-slate-200 z-40")),attr(r,"class",o=cn("w-3",{"border-b border-slate-200":a[1]})),attr(l,"class",cn("w-full sticky top-0 bg-white z-20")),attr(e,"class",c=cn("flex",a[0]))},m(p,_){insert_hydration(p,e,_),append_hydration(e,n),u&&u.m(n,null),append_hydration(e,t),append_hydration(e,r),append_hydration(e,s),append_hydration(e,l),d&&d.m(l,null),f=!0},p(p,[_]){u&&u.p&&(!f||_&4)&&update_slot_base(u,h,p,p[2],f?get_slot_changes(h,p[2],_,get_name_slot_changes):get_all_dirty_from_scope(p[2]),get_name_slot_context),(!f||_&2&&o!==(o=cn("w-3",{"border-b border-slate-200":p[1]})))&&attr(r,"class",o),d&&d.p&&(!f||_&4)&&update_slot_base(d,i,p,p[2],f?get_slot_changes(i,p[2],_,get_timeTrack_slot_changes):get_all_dirty_from_scope(p[2]),get_timeTrack_slot_context),(!f||_&1&&c!==(c=cn("flex",p[0])))&&attr(e,"class",c)},i(p){f||(transition_in(u,p),transition_in(d,p),f=!0)},o(p){transition_out(u,p),transition_out(d,p),f=!1},d(p){p&&detach(e),u&&u.d(p),d&&d.d(p)}}}function instance$5(a,e,n){let{$$slots:t={},$$scope:r}=e,{class:o=void 0}=e,{isTopRow:s=!1}=e;return a.$$set=l=>{"class"in l&&n(0,o=l.class),"isTopRow"in l&&n(1,s=l.isTopRow),"$$scope"in l&&n(2,r=l.$$scope)},[o,s,r,t]}class VideoPlayerRow extends SvelteComponent{constructor(e){super(),init(this,e,instance$5,create_fragment$7,safe_not_equal,{class:0,isTopRow:1})}}function get_each_context(a,e,n){const t=a.slice();return t[16]=e[n],t}function create_if_block$4(a){let e,n,t,r,o;n=new VideoPlayerRow({props:{class:"sticky top-0 bg-white z-20",isTopRow:!0,$$slots:{timeTrack:[create_timeTrack_slot_1],name:[create_name_slot_1]},$$scope:{ctx:a}}});let s=ensure_array_like(Object.values(a[8])),l=[];for(let f=0;f<s.length;f+=1)l[f]=create_each_block(get_each_context(a,s,f));const c=f=>transition_out(l[f],1,1,()=>{l[f]=null});return{c(){e=element("div"),create_component(n.$$.fragment),t=space(),r=element("div");for(let f=0;f<l.length;f+=1)l[f].c();this.h()},l(f){e=claim_element(f,"DIV",{class:!0});var h=children(e);claim_component(n.$$.fragment,h),t=claim_space(h),r=claim_element(h,"DIV",{class:!0});var u=children(r);for(let i=0;i<l.length;i+=1)l[i].l(u);u.forEach(detach),h.forEach(detach),this.h()},h(){attr(r,"class","flex flex-col max-h-[150px] z-10 relative"),attr(e,"class","h-full bg-white overflow-x-auto")},m(f,h){insert_hydration(f,e,h),mount_component(n,e,null),append_hydration(e,t),append_hydration(e,r);for(let u=0;u<l.length;u+=1)l[u]&&l[u].m(r,null);o=!0},p(f,h){const u={};if(h&524525&&(u.$$scope={dirty:h,ctx:f}),n.$set(u),h&902){s=ensure_array_like(Object.values(f[8]));let i;for(i=0;i<s.length;i+=1){const d=get_each_context(f,s,i);l[i]?(l[i].p(d,h),transition_in(l[i],1)):(l[i]=create_each_block(d),l[i].c(),transition_in(l[i],1),l[i].m(r,null))}for(group_outros(),i=s.length;i<l.length;i+=1)c(i);check_outros()}},i(f){if(!o){transition_in(n.$$.fragment,f);for(let h=0;h<s.length;h+=1)transition_in(l[h]);o=!0}},o(f){transition_out(n.$$.fragment,f),l=l.filter(Boolean);for(let h=0;h<l.length;h+=1)transition_out(l[h]);o=!1},d(f){f&&detach(e),destroy_component(n),destroy_each(l,f)}}}function create_else_block(a){let e,n;return e=new Play({}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_if_block_2$1(a){let e,n;return e=new Pause({}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_name_slot_1(a){let e,n,t,r,o,s,l,c,f,h,u,i,d;function p(v){a[13](v)}let _={min:100,max:200};a[7]!==void 0&&(_.value=a[7]),o=new SliderRoot({props:_}),binding_callbacks.push(()=>bind(o,"value",p));const m=[create_if_block_2$1,create_else_block],g=[];function b(v,T){return v[3]?0:1}return f=b(a),h=g[f]=m[f](a),{c(){e=element("div"),n=element("p"),t=text(a[5]),r=space(),create_component(o.$$.fragment),l=space(),c=element("button"),h.c(),this.h()},l(v){e=claim_element(v,"DIV",{slot:!0,class:!0});var T=children(e);n=claim_element(T,"P",{});var y=children(n);t=claim_text(y,a[5]),y.forEach(detach),r=claim_space(T),claim_component(o.$$.fragment,T),l=claim_space(T),c=claim_element(T,"BUTTON",{class:!0});var w=children(c);h.l(w),w.forEach(detach),T.forEach(detach),this.h()},h(){attr(c,"class","text-primary"),attr(e,"slot","name"),attr(e,"class","bg-white flex justify-between items-center gap-4 p-4 border-b border-slate-200")},m(v,T){insert_hydration(v,e,T),append_hydration(e,n),append_hydration(n,t),append_hydration(e,r),mount_component(o,e,null),append_hydration(e,l),append_hydration(e,c),g[f].m(c,null),u=!0,i||(d=listen(c,"click",a[10]),i=!0)},p(v,T){(!u||T&32)&&set_data(t,v[5]);const y={};!s&&T&128&&(s=!0,y.value=v[7],add_flush_callback(()=>s=!1)),o.$set(y);let w=f;f=b(v),f!==w&&(group_outros(),transition_out(g[w],1,1,()=>{g[w]=null}),check_outros(),h=g[f],h||(h=g[f]=m[f](v),h.c()),transition_in(h,1),h.m(c,null))},i(v){u||(transition_in(o.$$.fragment,v),transition_in(h),u=!0)},o(v){transition_out(o.$$.fragment,v),transition_out(h),u=!1},d(v){v&&detach(e),destroy_component(o),g[f].d(),i=!1,d()}}}function create_timeTrack_slot_1(a){let e,n,t,r;function o(c){a[11](c)}function s(c){a[12](c)}let l={slot:"timeTrack",updateView:a[0],videoSpeed,intervalId:a[3],zoomLevel:a[7]};return a[6]!==void 0&&(l.cursorElement=a[6]),a[2]!==void 0&&(l.currentImageIndex=a[2]),e=new TimeTrack({props:l}),binding_callbacks.push(()=>bind(e,"cursorElement",o)),binding_callbacks.push(()=>bind(e,"currentImageIndex",s)),{c(){create_component(e.$$.fragment)},l(c){claim_component(e.$$.fragment,c)},m(c,f){mount_component(e,c,f),r=!0},p(c,f){const h={};f&1&&(h.updateView=c[0]),f&8&&(h.intervalId=c[3]),f&128&&(h.zoomLevel=c[7]),!n&&f&64&&(n=!0,h.cursorElement=c[6],add_flush_callback(()=>n=!1)),!t&&f&4&&(t=!0,h.currentImageIndex=c[2],add_flush_callback(()=>t=!1)),e.$set(h)},i(c){r||(transition_in(e.$$.fragment,c),r=!0)},o(c){transition_out(e.$$.fragment,c),r=!1},d(c){destroy_component(e,c)}}}function create_if_block_1$2(a){let e,n;return e=new VideoPlayerRow({props:{$$slots:{timeTrack:[create_timeTrack_slot],name:[create_name_slot]},$$scope:{ctx:a}}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r&524678&&(o.$$scope={dirty:r,ctx:t}),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_name_slot(a){let e,n=a[16].id+"",t,r;return{c(){e=element("p"),t=text(n),r=space(),this.h()},l(o){e=claim_element(o,"P",{slot:!0,class:!0});var s=children(e);t=claim_text(s,n),r=claim_space(s),s.forEach(detach),this.h()},h(){attr(e,"slot","name"),attr(e,"class","py-4 sticky left-0 bg-white text-ellipsis overflow-hidden p-2")},m(o,s){insert_hydration(o,e,s),append_hydration(e,t),append_hydration(e,r)},p(o,s){s&256&&n!==(n=o[16].id+"")&&set_data(t,n)},d(o){o&&detach(e)}}}function create_timeTrack_slot(a){let e,n;return e=new ObjectTrack({props:{slot:"timeTrack",zoomLevel:a[7],object:a[16],onTimeTrackClick:a[9],colorScale:a[1],currentImageIndex:a[2]}}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p(t,r){const o={};r&128&&(o.zoomLevel=t[7]),r&256&&(o.object=t[16]),r&2&&(o.colorScale=t[1]),r&4&&(o.currentImageIndex=t[2]),e.$set(o)},i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_each_block(a){let e,n,t=a[16].datasetItemType==="video"&&create_if_block_1$2(a);return{c(){t&&t.c(),e=empty()},l(r){t&&t.l(r),e=empty()},m(r,o){t&&t.m(r,o),insert_hydration(r,e,o),n=!0},p(r,o){r[16].datasetItemType==="video"?t?(t.p(r,o),o&256&&transition_in(t,1)):(t=create_if_block_1$2(r),t.c(),transition_in(t,1),t.m(e.parentNode,e)):t&&(group_outros(),transition_out(t,1,1,()=>{t=null}),check_outros())},i(r){n||(transition_in(t),n=!0)},o(r){transition_out(t),n=!1},d(r){r&&detach(e),t&&t.d(r)}}}function create_fragment$6(a){let e,n,t=a[4]&&create_if_block$4(a);return{c(){t&&t.c(),e=empty()},l(r){t&&t.l(r),e=empty()},m(r,o){t&&t.m(r,o),insert_hydration(r,e,o),n=!0},p(r,[o]){r[4]?t?(t.p(r,o),o&16&&transition_in(t,1)):(t=create_if_block$4(r),t.c(),transition_in(t,1),t.m(e.parentNode,e)):t&&(group_outros(),transition_out(t,1,1,()=>{t=null}),check_outros())},i(r){n||(transition_in(t),n=!0)},o(r){transition_out(t),n=!1},d(r){r&&detach(e),t&&t.d(r)}}}let videoSpeed=100;function instance$4(a,e,n){let t,r;component_subscribe(a,lastFrameIndex,v=>n(14,t=v)),component_subscribe(a,itemObjects,v=>n(8,r=v));let{updateView:o}=e,{colorScale:s}=e,l=0,c,f=!1,h,u,i=[0];onMount(()=>{o(l),n(4,f=!0)}),onDestroy(()=>{clearInterval(c)});const d=()=>{if(!f)return;clearInterval(c);const v=setInterval(()=>{n(2,l=(l+1)%(t+1)),u.scrollIntoView({block:"nearest",inline:"center"}),o(l)},videoSpeed);n(3,c=Number(v))},p=v=>{n(2,l=v),o(l)},_=()=>{c?(clearInterval(c),n(3,c=0)):d()};function m(v){u=v,n(6,u)}function g(v){l=v,n(2,l)}function b(v){i=v,n(7,i)}return a.$$set=v=>{"updateView"in v&&n(0,o=v.updateView),"colorScale"in v&&n(1,s=v.colorScale)},a.$$.update=()=>{a.$$.dirty&4&&n(5,h=getCurrentImageTime(l,videoSpeed))},[o,s,l,c,f,h,u,i,r,p,_,m,g,b]}class VideoPlayer extends SvelteComponent{constructor(e){super(),init(this,e,instance$4,create_fragment$6,safe_not_equal,{updateView:0,colorScale:1})}}function create_if_block$3(a){let e,n,t,r,o,s,l,c,f;function h(p){a[13](p)}function u(p){a[14](p)}function i(p){a[15](p)}let d={selectedItemId:a[1].id,imagesPerView:a[6],colorRange:a[3],bboxes:a[8],masks:a[9],embeddings:a[2]};return a[4]!==void 0&&(d.selectedTool=a[4]),a[0]!==void 0&&(d.currentAnn=a[0]),a[5]!==void 0&&(d.newShape=a[5]),n=new Canvas2D({props:d}),binding_callbacks.push(()=>bind(n,"selectedTool",h)),binding_callbacks.push(()=>bind(n,"currentAnn",u)),binding_callbacks.push(()=>bind(n,"newShape",i)),c=new VideoPlayer({props:{updateView:a[11],colorScale:a[10]}}),{c(){e=element("div"),create_component(n.$$.fragment),s=space(),l=element("div"),create_component(c.$$.fragment),this.h()},l(p){e=claim_element(p,"DIV",{class:!0});var _=children(e);claim_component(n.$$.fragment,_),_.forEach(detach),s=claim_space(p),l=claim_element(p,"DIV",{class:!0});var m=children(l);claim_component(c.$$.fragment,m),m.forEach(detach),this.h()},h(){attr(e,"class","overflow-hidden grow"),attr(l,"class","h-full grow max-h-[25%]")},m(p,_){insert_hydration(p,e,_),mount_component(n,e,null),insert_hydration(p,s,_),insert_hydration(p,l,_),mount_component(c,l,null),f=!0},p(p,_){const m={};_&2&&(m.selectedItemId=p[1].id),_&64&&(m.imagesPerView=p[6]),_&8&&(m.colorRange=p[3]),_&256&&(m.bboxes=p[8]),_&512&&(m.masks=p[9]),_&4&&(m.embeddings=p[2]),!t&&_&16&&(t=!0,m.selectedTool=p[4],add_flush_callback(()=>t=!1)),!r&&_&1&&(r=!0,m.currentAnn=p[0],add_flush_callback(()=>r=!1)),!o&&_&32&&(o=!0,m.newShape=p[5],add_flush_callback(()=>o=!1)),n.$set(m)},i(p){f||(transition_in(n.$$.fragment,p),transition_in(c.$$.fragment,p),f=!0)},o(p){transition_out(n.$$.fragment,p),transition_out(c.$$.fragment,p),f=!1},d(p){p&&(detach(e),detach(s),detach(l)),destroy_component(n),destroy_component(c)}}}function create_fragment$5(a){let e,n,t=a[7]&&create_if_block$3(a);return{c(){e=element("section"),t&&t.c(),this.h()},l(r){e=claim_element(r,"SECTION",{class:!0});var o=children(e);t&&t.l(o),o.forEach(detach),this.h()},h(){attr(e,"class","pl-4 h-full w-full flex flex-col")},m(r,o){insert_hydration(r,e,o),t&&t.m(e,null),n=!0},p(r,[o]){r[7]?t?(t.p(r,o),o&128&&transition_in(t,1)):(t=create_if_block$3(r),t.c(),transition_in(t,1),t.m(e,null)):t&&(group_outros(),transition_out(t,1,1,()=>{t=null}),check_outros())},i(r){n||(transition_in(t),n=!0)},o(r){transition_out(t),n=!1},d(r){r&&detach(e),t&&t.d()}}}function instance$3(a,e,n){var T;let t,r,o,s,l;component_subscribe(a,selectedTool,y=>n(4,t=y)),component_subscribe(a,newShape,y=>n(5,r=y)),component_subscribe(a,itemBoxBeingEdited,y=>n(12,o=y)),component_subscribe(a,itemBboxes,y=>n(8,s=y)),component_subscribe(a,itemMasks,y=>n(9,l=y));let{selectedItem:c}=e,{embeddings:f}=e,{currentAnn:h=null}=e,{colorRange:u}=e,i={},d=((T=c.views.image)==null?void 0:T.map(y=>y.uri))||[],p=!1,_=ordinalColorScale(u);onMount(()=>{const y=new Image;y.src=d[0],n(6,i={...i,image:[y]}),n(7,p=!0),lastFrameIndex.set(d.length-1)});const m=y=>{const w=new Image,S=d[y];S&&(w.src=S,n(6,i.image=[...i.image||[],w].slice(-2),i),itemObjects.update(O=>O.map(P=>{if(P.datasetItemType!=="video")return P;const{displayedBox:E}=P,A=linearInterpolation(P.track,y);if(A){const[$,k,D,I]=A;E.coords=[$,k,D,I],E.frameIndex=y}return E.displayControl={...E.displayControl,hidden:!A},E.hidden=!A,{...P,displayedBox:E}})))};function g(y){t=y,selectedTool.set(t)}function b(y){h=y,n(0,h)}function v(y){r=y,newShape.set(r)}return a.$$set=y=>{"selectedItem"in y&&n(1,c=y.selectedItem),"embeddings"in y&&n(2,f=y.embeddings),"currentAnn"in y&&n(0,h=y.currentAnn),"colorRange"in y&&n(3,u=y.colorRange)},a.$$.update=()=>{if(a.$$.dirty&4128){const y=r,w=o;y.status==="editing"&&(w?itemObjects.update(S=>editKeyBoxInTracklet(S,w,y)):itemObjects.update(S=>updateExistingObject(S,r)))}a.$$.dirty&16&&selectedTool.set(t)},[h,c,f,u,t,r,i,p,s,l,_,m,o,g,b,v]}class VideoViewer extends SvelteComponent{constructor(e){super(),init(this,e,instance$3,create_fragment$5,safe_not_equal,{selectedItem:1,embeddings:2,currentAnn:0,colorRange:3})}}function create_fragment$4(a){let e,n="Display here the 3D viewer";return{c(){e=element("div"),e.textContent=n,this.h()},l(t){e=claim_element(t,"DIV",{class:!0,"data-svelte-h":!0}),get_svelte_dataset(e)!=="svelte-112fjhm"&&(e.textContent=n),this.h()},h(){attr(e,"class","bg-white p-12")},m(t,r){insert_hydration(t,e,r)},p:noop,i:noop,o:noop,d(t){t&&detach(e)}}}class Canvas3D extends SvelteComponent{constructor(e){super(),init(this,e,null,create_fragment$4,safe_not_equal,{})}}function create_fragment$3(a){let e,n;return e=new Canvas3D({}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p:noop,i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}class _3DViewer extends SvelteComponent{constructor(e){super(),init(this,e,null,create_fragment$3,safe_not_equal,{})}}function create_if_block_3(a){let e,n;return e=new _3DViewer({}),{c(){create_component(e.$$.fragment)},l(t){claim_component(e.$$.fragment,t)},m(t,r){mount_component(e,t,r),n=!0},p:noop,i(t){n||(transition_in(e.$$.fragment,t),n=!0)},o(t){transition_out(e.$$.fragment,t),n=!1},d(t){destroy_component(e,t)}}}function create_if_block_2(a){let e,n,t;function r(s){a[8](s)}let o={selectedItem:a[1],embeddings:a[2],colorRange:a[4]};return a[0]!==void 0&&(o.currentAnn=a[0]),e=new ImageViewer({props:o}),binding_callbacks.push(()=>bind(e,"currentAnn",r)),{c(){create_component(e.$$.fragment)},l(s){claim_component(e.$$.fragment,s)},m(s,l){mount_component(e,s,l),t=!0},p(s,l){const c={};l&2&&(c.selectedItem=s[1]),l&4&&(c.embeddings=s[2]),l&16&&(c.colorRange=s[4]),!n&&l&1&&(n=!0,c.currentAnn=s[0],add_flush_callback(()=>n=!1)),e.$set(c)},i(s){t||(transition_in(e.$$.fragment,s),t=!0)},o(s){transition_out(e.$$.fragment,s),t=!1},d(s){destroy_component(e,s)}}}function create_if_block_1$1(a){let e,n,t;function r(s){a[7](s)}let o={selectedItem:a[1],embeddings:a[2],colorRange:a[4]};return a[0]!==void 0&&(o.currentAnn=a[0]),e=new VideoViewer({props:o}),binding_callbacks.push(()=>bind(e,"currentAnn",r)),{c(){create_component(e.$$.fragment)},l(s){claim_component(e.$$.fragment,s)},m(s,l){mount_component(e,s,l),t=!0},p(s,l){const c={};l&2&&(c.selectedItem=s[1]),l&4&&(c.embeddings=s[2]),l&16&&(c.colorRange=s[4]),!n&&l&1&&(n=!0,c.currentAnn=s[0],add_flush_callback(()=>n=!1)),e.$set(c)},i(s){t||(transition_in(e.$$.fragment,s),t=!0)},o(s){transition_out(e.$$.fragment,s),t=!1},d(s){destroy_component(e,s)}}}function create_if_block$2(a){let e,n,t;return n=new Loader_2({props:{class:"animate-spin text-white"}}),{c(){e=element("div"),create_component(n.$$.fragment),this.h()},l(r){e=claim_element(r,"DIV",{class:!0});var o=children(e);claim_component(n.$$.fragment,o),o.forEach(detach),this.h()},h(){attr(e,"class","h-full w-full flex justify-center items-center")},m(r,o){insert_hydration(r,e,o),mount_component(n,e,null),t=!0},p:noop,i(r){t||(transition_in(n.$$.fragment,r),t=!0)},o(r){transition_out(n.$$.fragment,r),t=!1},d(r){r&&detach(e),destroy_component(n)}}}function create_fragment$2(a){let e,n,t,r;const o=[create_if_block$2,create_if_block_1$1,create_if_block_2,create_if_block_3],s=[];function l(c,f){return c[3]?0:c[1].type==="video"?1:c[1].type==="image"||!c[1].type?2:c[1].type==="3d"?3:-1}return~(n=l(a))&&(t=s[n]=o[n](a)),{c(){e=element("div"),t&&t.c(),this.h()},l(c){e=claim_element(c,"DIV",{class:!0});var f=children(e);t&&t.l(f),f.forEach(detach),this.h()},h(){attr(e,"class","max-w-[100%] bg-slate-800")},m(c,f){insert_hydration(c,e,f),~n&&s[n].m(e,null),r=!0},p(c,[f]){let h=n;n=l(c),n===h?~n&&s[n].p(c,f):(t&&(group_outros(),transition_out(s[h],1,1,()=>{s[h]=null}),check_outros()),~n?(t=s[n],t?t.p(c,f):(t=s[n]=o[n](c),t.c()),transition_in(t,1),t.m(e,null)):t=null)},i(c){r||(transition_in(t),r=!0)},o(c){transition_out(t),r=!1},d(c){c&&detach(e),~n&&s[n].d()}}}function instance$2(a,e,n){let t,r;component_subscribe(a,newShape,i=>n(5,t=i)),component_subscribe(a,preAnnotationIsActive,i=>n(6,r=i));let{selectedItem:o}=e,{embeddings:s}=e,{currentAnn:l=null}=e,{isLoading:c}=e,f=[];itemObjects.subscribe(i=>{n(4,f=i.map(d=>d.id))});function h(i){l=i,n(0,l)}function u(i){l=i,n(0,l)}return a.$$set=i=>{"selectedItem"in i&&n(1,o=i.selectedItem),"embeddings"in i&&n(2,s=i.embeddings),"currentAnn"in i&&n(0,l=i.currentAnn),"isLoading"in i&&n(3,c=i.isLoading)},a.$$.update=()=>{a.$$.dirty&96&&(newShape.set(t),(t==null?void 0:t.status)==="editing"&&!r&&(itemObjects.update(i=>updateExistingObject(i,t)),canSave.update(i=>i||(t==null?void 0:t.status)==="editing"&&t.type!=="none")))},[l,o,s,c,f,t,r,h,u]}class DatasetItemViewer extends SvelteComponent{constructor(e){super(),init(this,e,instance$2,create_fragment$2,safe_not_equal,{selectedItem:1,embeddings:2,currentAnn:0,isLoading:3})}}function create_if_block$1(a){let e,n,t;return n=new Loader_2({props:{class:"animate-spin"}}),{c(){e=element("div"),create_component(n.$$.fragment),this.h()},l(r){e=claim_element(r,"DIV",{class:!0});var o=children(e);claim_component(n.$$.fragment,o),o.forEach(detach),this.h()},h(){attr(e,"class","h-full w-full flex justify-center items-center absolute top-0 left-0 bg-slate-300 z-50 opacity-30")},m(r,o){insert_hydration(r,e,o),mount_component(n,e,null),t=!0},i(r){t||(transition_in(n.$$.fragment,r),t=!0)},o(r){transition_out(n.$$.fragment,r),t=!1},d(r){r&&detach(e),destroy_component(n)}}}function create_fragment$1(a){let e,n,t,r,o,s,l,c,f,h,u,i=a[4]&&create_if_block$1();t=new Toolbar({}),o=new DatasetItemViewer({props:{selectedItem:a[1],embeddings:a[5],isLoading:a[3]}}),l=new InspectorInspector({props:{isLoading:a[3]}}),l.$on("click",a[6]);function d(_){a[10](_)}let p={models:a[2],currentDatasetId:a[0].id,selectedItemId:a[1].id};return a[5]!==void 0&&(p.embeddings=a[5]),f=new LoadModelModal({props:p}),binding_callbacks.push(()=>bind(f,"embeddings",d)),{c(){e=element("div"),i&&i.c(),n=space(),create_component(t.$$.fragment),r=space(),create_component(o.$$.fragment),s=space(),create_component(l.$$.fragment),c=space(),create_component(f.$$.fragment),this.h()},l(_){e=claim_element(_,"DIV",{class:!0});var m=children(e);i&&i.l(m),n=claim_space(m),claim_component(t.$$.fragment,m),r=claim_space(m),claim_component(o.$$.fragment,m),s=claim_space(m),claim_component(l.$$.fragment,m),c=claim_space(m),claim_component(f.$$.fragment,m),m.forEach(detach),this.h()},h(){attr(e,"class","w-full h-full grid grid-cols-[48px_calc(100%-380px-48px)_380px]")},m(_,m){insert_hydration(_,e,m),i&&i.m(e,null),append_hydration(e,n),mount_component(t,e,null),append_hydration(e,r),mount_component(o,e,null),append_hydration(e,s),mount_component(l,e,null),append_hydration(e,c),mount_component(f,e,null),u=!0},p(_,[m]){_[4]?i?m&16&&transition_in(i,1):(i=create_if_block$1(),i.c(),transition_in(i,1),i.m(e,n)):i&&(group_outros(),transition_out(i,1,1,()=>{i=null}),check_outros());const g={};m&2&&(g.selectedItem=_[1]),m&32&&(g.embeddings=_[5]),m&8&&(g.isLoading=_[3]),o.$set(g);const b={};m&8&&(b.isLoading=_[3]),l.$set(b);const v={};m&4&&(v.models=_[2]),m&1&&(v.currentDatasetId=_[0].id),m&2&&(v.selectedItemId=_[1].id),!h&&m&32&&(h=!0,v.embeddings=_[5],add_flush_callback(()=>h=!1)),f.$set(v)},i(_){u||(transition_in(i),transition_in(t.$$.fragment,_),transition_in(o.$$.fragment,_),transition_in(l.$$.fragment,_),transition_in(f.$$.fragment,_),u=!0)},o(_){transition_out(i),transition_out(t.$$.fragment,_),transition_out(o.$$.fragment,_),transition_out(l.$$.fragment,_),transition_out(f.$$.fragment,_),u=!1},d(_){_&&detach(e),i&&i.d(),destroy_component(t),destroy_component(o),destroy_component(l),destroy_component(f)}}}function instance$1(a,e,n){let{currentDataset:t}=e,{selectedItem:r}=e,{models:o=[]}=e,{handleSaveItem:s}=e,{isLoading:l}=e,{canSaveCurrentItem:c}=e,{shouldSaveCurrentItem:f}=e,h=!1,u={};canSave.subscribe(p=>n(7,c=p));const i=async()=>{n(4,h=!0);let p={...r};itemObjects.subscribe(_=>{p.objects=_.reduce((m,g)=>(m[g.id]=g,m),{})}),itemMetas.subscribe(_=>{p.features=_.mainFeatures}),await s(p),canSave.set(!1),n(4,h=!1)};function d(p){u=p,n(5,u)}return a.$$set=p=>{"currentDataset"in p&&n(0,t=p.currentDataset),"selectedItem"in p&&n(1,r=p.selectedItem),"models"in p&&n(2,o=p.models),"handleSaveItem"in p&&n(8,s=p.handleSaveItem),"isLoading"in p&&n(3,l=p.isLoading),"canSaveCurrentItem"in p&&n(7,c=p.canSaveCurrentItem),"shouldSaveCurrentItem"in p&&n(9,f=p.shouldSaveCurrentItem)},a.$$.update=()=>{var p;a.$$.dirty&2&&itemObjects.update(_=>Object.values(r.objects||{}).flat().map(m=>{const g=_.find(b=>b.id===m.id);return g?{...g,...m}:m})),a.$$.dirty&3&&itemMetas.set({mainFeatures:r.features,objectFeatures:(p=Object.values(r.objects||{})[0])==null?void 0:p.features,featuresList:t.features_values||{main:{},objects:{}},views:r.views,id:r.id,type:r.type}),a.$$.dirty&2&&r&&(newShape.update(_=>({..._,status:"none"})),canSave.set(!1)),a.$$.dirty&512&&f&&i().catch(_=>console.error(_))},[t,r,o,l,h,u,i,c,s,f,d]}class DatasetItemWorkspace extends SvelteComponent{constructor(e){super(),init(this,e,instance$1,create_fragment$1,safe_not_equal,{currentDataset:0,selectedItem:1,models:2,handleSaveItem:8,isLoading:3,canSaveCurrentItem:7,shouldSaveCurrentItem:9})}}function create_if_block_1(a){let e,n,t,r;function o(l){a[10](l)}let s={selectedItem:a[0],models:a[3],currentDataset:a[1],handleSaveItem:a[8],isLoading:a[5],shouldSaveCurrentItem:a[6]};return a[2]!==void 0&&(s.canSaveCurrentItem=a[2]),n=new DatasetItemWorkspace({props:s}),binding_callbacks.push(()=>bind(n,"canSaveCurrentItem",o)),{c(){e=element("div"),create_component(n.$$.fragment),this.h()},l(l){e=claim_element(l,"DIV",{class:!0});var c=children(e);claim_component(n.$$.fragment,c),c.forEach(detach),this.h()},h(){attr(e,"class","pt-20 h-1 min-h-screen")},m(l,c){insert_hydration(l,e,c),mount_component(n,e,null),r=!0},p(l,c){const f={};c&1&&(f.selectedItem=l[0]),c&8&&(f.models=l[3]),c&2&&(f.currentDataset=l[1]),c&32&&(f.isLoading=l[5]),c&64&&(f.shouldSaveCurrentItem=l[6]),!t&&c&4&&(t=!0,f.canSaveCurrentItem=l[2],add_flush_callback(()=>t=!1)),n.$set(f)},i(l){r||(transition_in(n.$$.fragment,l),r=!0)},o(l){transition_out(n.$$.fragment,l),r=!1},d(l){l&&detach(e),destroy_component(n)}}}function create_if_block(a){let e,n,t="Current item could not be loaded",r,o,s;return o=new PrimaryButton({props:{$$slots:{default:[create_default_slot]},$$scope:{ctx:a}}}),o.$on("click",a[11]),{c(){e=element("div"),n=element("p"),n.textContent=t,r=space(),create_component(o.$$.fragment),this.h()},l(l){e=claim_element(l,"DIV",{class:!0});var c=children(e);n=claim_element(c,"P",{"data-svelte-h":!0}),get_svelte_dataset(n)!=="svelte-7sd7em"&&(n.textContent=t),r=claim_space(c),claim_component(o.$$.fragment,c),c.forEach(detach),this.h()},h(){attr(e,"class","w-full pt-40 text-center flex flex-col gap-5 items-center")},m(l,c){insert_hydration(l,e,c),append_hydration(e,n),append_hydration(e,r),mount_component(o,e,null),s=!0},p(l,c){const f={};c&8192&&(f.$$scope={dirty:c,ctx:l}),o.$set(f)},i(l){s||(transition_in(o.$$.fragment,l),s=!0)},o(l){transition_out(o.$$.fragment,l),s=!1},d(l){l&&detach(e),destroy_component(o)}}}function create_default_slot(a){let e;return{c(){e=text("Back to dataset")},l(n){e=claim_text(n,"Back to dataset")},m(n,t){insert_hydration(n,e,t)},d(n){n&&detach(e)}}}function create_fragment(a){let e,n,t,r=a[0]&&a[1]&&create_if_block_1(a),o=!a[0]&&a[7]&&create_if_block(a);return{c(){r&&r.c(),e=space(),o&&o.c(),n=empty()},l(s){r&&r.l(s),e=claim_space(s),o&&o.l(s),n=empty()},m(s,l){r&&r.m(s,l),insert_hydration(s,e,l),o&&o.m(s,l),insert_hydration(s,n,l),t=!0},p(s,[l]){s[0]&&s[1]?r?(r.p(s,l),l&3&&transition_in(r,1)):(r=create_if_block_1(s),r.c(),transition_in(r,1),r.m(e.parentNode,e)):r&&(group_outros(),transition_out(r,1,1,()=>{r=null}),check_outros()),!s[0]&&s[7]?o?(o.p(s,l),l&129&&transition_in(o,1)):(o=create_if_block(s),o.c(),transition_in(o,1),o.m(n.parentNode,n)):o&&(group_outros(),transition_out(o,1,1,()=>{o=null}),check_outros())},i(s){t||(transition_in(r),transition_in(o),t=!0)},o(s){transition_out(r),transition_out(o),t=!1},d(s){s&&(detach(e),detach(n)),r&&r.d(s),o&&o.d(s)}}}function instance(a,e,n){let t,r,o,s,l,c=!1,f=!1,h=!1,u=!1;modelsStore$1.subscribe(m=>{n(3,o=m)}),saveCurrentItemStore.subscribe(m=>{n(2,f=m.canSave),n(6,h=m.shouldSave)});const i=(m,g)=>{m&&getDatasetItem(m.id,encodeURIComponent(g)).then(b=>{n(0,t=b),Object.keys(b).length===0?n(7,u=!0):n(7,u=!1)}).then(()=>isLoadingNewItemStore.set(!1)).catch(b=>console.error(b))};page.subscribe(m=>{n(4,s=m.params.dataset),n(9,l=m.params.itemId)}),datasetsStore.subscribe(m=>{const g=m==null?void 0:m.find(b=>b.name===s);console.log({value:m}),g&&n(1,r=g)});async function d(m){await postDatasetItem(r.id,m),i(r,l),saveCurrentItemStore.update(g=>({...g,shouldSave:!1}))}function p(m){f=m,n(2,f)}const _=()=>goto(`/${s}/dataset`);return a.$$.update=()=>{a.$$.dirty&4&&saveCurrentItemStore.update(m=>({...m,canSave:f})),a.$$.dirty&515&&l!==(t==null?void 0:t.id)&&(isLoadingNewItemStore.set(!0),i(r,l))},isLoadingNewItemStore.subscribe(m=>{n(5,c=m)}),[t,r,f,o,s,c,h,u,d,l,p,_]}class Page extends SvelteComponent{constructor(e){super(),init(this,e,instance,create_fragment,safe_not_equal,{})}}export{Page as component,_page as universal};
