@htmlbricks/hb-stylus-notebook 0.65.22 → 0.66.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/main.iife.js CHANGED
@@ -1,3 +1,3 @@
1
- (function(Tt){"use strict";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add("5");const Fn=2,St="[",Nt="[!",kt="]",Se={},T=Symbol(),In="http://www.w3.org/1999/xhtml",nt=!1;var qn=Array.isArray,Bn=Array.prototype.indexOf,Un=Array.from,Fe=Object.keys,Ie=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,Hn=Object.getOwnPropertyDescriptors,Yn=Object.prototype,Jn=Array.prototype,At=Object.getPrototypeOf,Ot=Object.isExtensible;function Vn(e){for(var t=0;t<e.length;t++)e[t]()}function Ct(){var e,t,n=new Promise((r,i)=>{e=r,t=i});return{promise:n,resolve:e,reject:t}}const x=2,rt=4,it=8,V=16,ne=32,re=64,qe=128,q=512,N=1024,O=2048,W=4096,ie=8192,G=16384,Be=32768,Ue=65536,Rt=1<<17,Lt=1<<18,ae=1<<19,Wn=1<<20,ue=32768,st=1<<21,lt=1<<22,se=1<<23,ot=Symbol("$state"),Gn=Symbol("legacy props"),zn=Symbol(""),ye=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"},Dt=3,He=8;function Kn(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Xn(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function Zn(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function Qn(e){throw new Error("https://svelte.dev/e/effect_orphan")}function er(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function tr(){throw new Error("https://svelte.dev/e/hydration_failed")}function nr(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function rr(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function ir(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function sr(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}function ft(e){console.warn("https://svelte.dev/e/hydration_mismatch")}function lr(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}let m=!1;function we(e){m=e}let w;function z(e){if(e===null)throw ft(),Se;return w=e}function Pt(){return z(X(w))}function Mt(e){if(m){if(X(w)!==null)throw ft(),Se;w=e}}function or(e=1){if(m){for(var t=e,n=w;t--;)n=X(n);w=n}}function fr(e=!0){for(var t=0,n=w;;){if(n.nodeType===He){var r=n.data;if(r===kt){if(t===0)return n;t-=1}else(r===St||r===Nt)&&(t+=1)}var i=X(n);e&&n.remove(),n=i}}function jt(e){return e===this.v}function ar(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function ur(e){return!ar(e,this.v)}let cr=!1,L=null;function me(e){L=e}function Ft(e,t=!1,n){L={p:L,i:!1,c:null,e:null,s:e,x:null,l:null}}function It(e){var t=L,n=t.e;if(n!==null){t.e=null;for(var r of n)sn(r)}return e!==void 0&&(t.x=e),t.i=!0,L=t.p,e??{}}function qt(){return!0}let ce=[];function Bt(){var e=ce;ce=[],Vn(e)}function Ye(e){if(ce.length===0&&!Ne){var t=ce;queueMicrotask(()=>{t===ce&&Bt()})}ce.push(e)}function dr(){for(;ce.length>0;)Bt()}function Ut(e){var t=g;if(t===null)return v.f|=se,e;if((t.f&Be)===0){if((t.f&qe)===0)throw e;t.b.error(e)}else be(e,t)}function be(e,t){for(;t!==null;){if((t.f&qe)!==0)try{t.b.error(e);return}catch(n){e=n}t=t.parent}throw e}const Je=new Set;let b=null,D=null,P=[],Ve=null,at=!1,Ne=!1;class B{committed=!1;current=new Map;previous=new Map;#t=new Set;#e=new Set;#f=0;#s=0;#a=null;#l=[];#i=[];skipped_effects=new Set;is_fork=!1;is_deferred(){return this.is_fork||this.#s>0}process(t){P=[],this.apply();var n={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const r of t)this.#n(r,n);this.is_fork||this.#u(),this.is_deferred()?(this.#r(n.effects),this.#r(n.render_effects),this.#r(n.block_effects)):(b=null,Yt(n.render_effects),Yt(n.effects),this.#a?.resolve()),D=null}#n(t,n){t.f^=N;for(var r=t.first;r!==null;){var i=r.f,s=(i&(ne|re))!==0,l=s&&(i&N)!==0,o=l||(i&ie)!==0||this.skipped_effects.has(r);if((r.f&qe)!==0&&r.b?.is_pending()&&(n={parent:n,effect:r,effects:[],render_effects:[],block_effects:[]}),!o&&r.fn!==null){s?r.f^=N:(i&rt)!==0?n.effects.push(r):Le(r)&&((r.f&V)!==0&&n.block_effects.push(r),De(r));var f=r.first;if(f!==null){r=f;continue}}var a=r.parent;for(r=r.next;r===null&&a!==null;)a===n.effect&&(this.#r(n.effects),this.#r(n.render_effects),this.#r(n.block_effects),n=n.parent),r=a.next,a=a.parent}}#r(t){for(const n of t)((n.f&O)!==0?this.#l:this.#i).push(n),this.#o(n.deps),A(n,N)}#o(t){if(t!==null)for(const n of t)(n.f&x)===0||(n.f&ue)===0||(n.f^=ue,this.#o(n.deps))}capture(t,n){this.previous.has(t)||this.previous.set(t,n),(t.f&se)===0&&(this.current.set(t,t.v),D?.set(t,t.v))}activate(){b=this,this.apply()}deactivate(){b===this&&(b=null,D=null)}flush(){if(this.activate(),P.length>0){if(Ht(),b!==null&&b!==this)return}else this.#f===0&&this.process([]);this.deactivate()}discard(){for(const t of this.#e)t(this);this.#e.clear()}#u(){if(this.#s===0){for(const t of this.#t)t();this.#t.clear()}this.#f===0&&this.#c()}#c(){if(Je.size>1){this.previous.clear();var t=D,n=!0,r={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const s of Je){if(s===this){n=!1;continue}const l=[];for(const[f,a]of this.current){if(s.current.has(f))if(n&&a!==s.current.get(f))s.current.set(f,a);else continue;l.push(f)}if(l.length===0)continue;const o=[...s.current.keys()].filter(f=>!this.current.has(f));if(o.length>0){var i=P;P=[];const f=new Set,a=new Map;for(const d of l)Jt(d,o,f,a);if(P.length>0){b=s,s.apply();for(const d of P)s.#n(d,r);s.deactivate()}P=i}}b=null,D=t}this.committed=!0,Je.delete(this)}increment(t){this.#f+=1,t&&(this.#s+=1)}decrement(t){this.#f-=1,t&&(this.#s-=1),this.revive()}revive(){for(const t of this.#l)A(t,O),$e(t);for(const t of this.#i)A(t,W),$e(t);this.#l=[],this.#i=[],this.flush()}oncommit(t){this.#t.add(t)}ondiscard(t){this.#e.add(t)}settled(){return(this.#a??=Ct()).promise}static ensure(){if(b===null){const t=b=new B;Je.add(b),Ne||B.enqueue(()=>{b===t&&t.flush()})}return b}static enqueue(t){Ye(t)}apply(){}}function ut(e){var t=Ne;Ne=!0;try{for(var n;;){if(dr(),P.length===0&&(b?.flush(),P.length===0))return Ve=null,n;Ht()}}finally{Ne=t}}function Ht(){var e=oe;at=!0;var t=null;try{var n=0;for(Xe(!0);P.length>0;){var r=B.ensure();if(n++>1e3){var i,s;hr()}r.process(P),le.clear()}}finally{at=!1,Xe(e),Ve=null}}function hr(){try{er()}catch(e){be(e,Ve)}}let K=null;function Yt(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if((r.f&(G|ie))===0&&Le(r)&&(K=new Set,De(r),r.deps===null&&r.first===null&&r.nodes_start===null&&(r.teardown===null&&r.ac===null?an(r):r.fn=null),K?.size>0)){le.clear();for(const i of K){if((i.f&(G|ie))!==0)continue;const s=[i];let l=i.parent;for(;l!==null;)K.has(l)&&(K.delete(l),s.push(l)),l=l.parent;for(let o=s.length-1;o>=0;o--){const f=s[o];(f.f&(G|ie))===0&&De(f)}}K.clear()}}K=null}}function Jt(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(const i of e.reactions){const s=i.f;(s&x)!==0?Jt(i,t,n,r):(s&(lt|V))!==0&&(s&O)===0&&Vt(i,t,r)&&(A(i,O),$e(i))}}function Vt(e,t,n){const r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(const i of e.deps){if(t.includes(i))return!0;if((i.f&x)!==0&&Vt(i,t,n))return n.set(i,!0),!0}return n.set(e,!1),!1}function $e(e){for(var t=Ve=e;t.parent!==null;){t=t.parent;var n=t.f;if(at&&t===g&&(n&V)!==0&&(n&Lt)===0)return;if((n&(re|ne))!==0){if((n&N)===0)return;t.f^=N}}P.push(t)}function _r(e){let t=0,n=ke(0),r;return()=>{ze()&&(c(n),ln(()=>(t===0&&(r=Br(()=>e(()=>Ae(n)))),t+=1,()=>{Ye(()=>{t-=1,t===0&&(r?.(),r=void 0,Ae(n))})})))}}var vr=Ue|ae|qe;function pr(e,t,n){new gr(e,t,n)}class gr{parent;#t=!1;#e;#f=m?w:null;#s;#a;#l;#i=null;#n=null;#r=null;#o=null;#u=null;#c=0;#d=0;#_=!1;#h=null;#w=_r(()=>(this.#h=ke(this.#c),()=>{this.#h=null}));constructor(t,n,r){this.#e=t,this.#s=n,this.#a=r,this.parent=g.b,this.#t=!!this.#s.pending,this.#l=Dr(()=>{if(g.b=this,m){const s=this.#f;Pt(),s.nodeType===He&&s.data===Nt?this.#b():this.#m()}else{var i=this.#g();try{this.#i=he(()=>r(i))}catch(s){this.error(s)}this.#d>0?this.#p():this.#t=!1}return()=>{this.#u?.remove()}},vr),m&&(this.#e=w)}#m(){try{this.#i=he(()=>this.#a(this.#e))}catch(t){this.error(t)}this.#t=!1}#b(){const t=this.#s.pending;t&&(this.#n=he(()=>t(this.#e)),B.enqueue(()=>{var n=this.#g();this.#i=this.#v(()=>(B.ensure(),he(()=>this.#a(n)))),this.#d>0?this.#p():(Ke(this.#n,()=>{this.#n=null}),this.#t=!1)}))}#g(){var t=this.#e;return this.#t&&(this.#u=Oe(),this.#e.before(this.#u),t=this.#u),t}is_pending(){return this.#t||!!this.parent&&this.parent.is_pending()}has_pending_snippet(){return!!this.#s.pending}#v(t){var n=g,r=v,i=L;M(this.#l),S(this.#l),me(this.#l.ctx);try{return t()}catch(s){return Ut(s),null}finally{M(n),S(r),me(i)}}#p(){const t=this.#s.pending;this.#i!==null&&(this.#o=document.createDocumentFragment(),this.#o.append(this.#u),Fr(this.#i,this.#o)),this.#n===null&&(this.#n=he(()=>t(this.#e)))}#y(t){if(!this.has_pending_snippet()){this.parent&&this.parent.#y(t);return}this.#d+=t,this.#d===0&&(this.#t=!1,this.#n&&Ke(this.#n,()=>{this.#n=null}),this.#o&&(this.#e.before(this.#o),this.#o=null))}update_pending_count(t){this.#y(t),this.#c+=t,this.#h&&Ge(this.#h,this.#c)}get_effect_pending(){return this.#w(),c(this.#h)}error(t){var n=this.#s.onerror;let r=this.#s.failed;if(this.#_||!n&&!r)throw t;this.#i&&(U(this.#i),this.#i=null),this.#n&&(U(this.#n),this.#n=null),this.#r&&(U(this.#r),this.#r=null),m&&(z(this.#f),or(),z(fr()));var i=!1,s=!1;const l=()=>{if(i){lr();return}i=!0,s&&sr(),B.ensure(),this.#c=0,this.#r!==null&&Ke(this.#r,()=>{this.#r=null}),this.#t=this.has_pending_snippet(),this.#i=this.#v(()=>(this.#_=!1,he(()=>this.#a(this.#e)))),this.#d>0?this.#p():this.#t=!1};var o=v;try{S(null),s=!0,n?.(t,l),s=!1}catch(f){be(f,this.#l&&this.#l.parent)}finally{S(o)}r&&Ye(()=>{this.#r=this.#v(()=>{B.ensure(),this.#_=!0;try{return he(()=>{r(this.#e,()=>t,()=>l)})}catch(f){return be(f,this.#l.parent),null}finally{this.#_=!1}})})}}function yr(e,t,n,r){const i=ct;if(n.length===0&&e.length===0){r(t.map(i));return}var s=b,l=g,o=wr();function f(){Promise.all(n.map(a=>mr(a))).then(a=>{o();try{r([...t.map(i),...a])}catch(d){(l.f&G)===0&&be(d,l)}s?.deactivate(),We()}).catch(a=>{be(a,l)})}e.length>0?Promise.all(e).then(()=>{o();try{return f()}finally{s?.deactivate(),We()}}):f()}function wr(){var e=g,t=v,n=L,r=b;return function(s=!0){M(e),S(t),me(n),s&&r?.activate()}}function We(){M(null),S(null),me(null)}function ct(e){var t=x|O,n=v!==null&&(v.f&x)!==0?v:null;return g!==null&&(g.f|=ae),{ctx:L,deps:null,effects:null,equals:jt,f:t,fn:e,reactions:null,rv:0,v:T,wv:0,parent:n??g,ac:null}}function mr(e,t){let n=g;n===null&&Kn();var r=n.b,i=void 0,s=ke(T),l=!v,o=new Map;return Lr(()=>{var f=Ct();i=f.promise;try{Promise.resolve(e()).then(f.resolve,f.reject).then(()=>{a===b&&a.committed&&a.deactivate(),We()})}catch(u){f.reject(u),We()}var a=b;if(l){var d=!r.is_pending();r.update_pending_count(1),a.increment(d),o.get(a)?.reject(ye),o.delete(a),o.set(a,f)}const _=(u,h=void 0)=>{if(a.activate(),h)h!==ye&&(s.f|=se,Ge(s,h));else{(s.f&se)!==0&&(s.f^=se),Ge(s,u);for(const[y,I]of o){if(o.delete(y),y===a)break;I.reject(ye)}}l&&(r.update_pending_count(-1),a.decrement(d))};f.promise.then(_,u=>_(null,u||"unknown"))}),rn(()=>{for(const f of o.values())f.reject(ye)}),new Promise(f=>{function a(d){function _(){d===i?f(s):a(i)}d.then(_,_)}a(i)})}function Wt(e){const t=ct(e);return dn(t),t}function Gt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)U(t[n])}}function br(e){for(var t=e.parent;t!==null;){if((t.f&x)===0)return(t.f&G)===0?t:null;t=t.parent}return null}function dt(e){var t,n=g;M(br(e));try{e.f&=~ue,Gt(e),t=gn(e)}finally{M(n)}return t}function zt(e){var t=dt(e);if(e.equals(t)||(b?.is_fork||(e.v=t),e.wv=vn()),!_e)if(D!==null)ze()&&D.set(e,t);else{var n=(e.f&q)===0?W:N;A(e,n)}}let ht=new Set;const le=new Map;let Kt=!1;function ke(e,t){var n={f:0,v:e,reactions:null,equals:jt,rv:0,wv:0};return n}function $(e,t){const n=ke(e);return dn(n),n}function $r(e,t=!1,n=!0){const r=ke(e);return t||(r.equals=ur),r}function E(e,t,n=!1){v!==null&&(!J||(v.f&Rt)!==0)&&qt()&&(v.f&(x|V|lt|Rt))!==0&&!Q?.includes(e)&&ir();let r=n?Ee(t):t;return Ge(e,r)}function Ge(e,t){if(!e.equals(t)){var n=e.v;_e?le.set(e,t):le.set(e,n),e.v=t;var r=B.ensure();r.capture(e,n),(e.f&x)!==0&&((e.f&O)!==0&&dt(e),A(e,(e.f&q)!==0?N:W)),e.wv=vn(),Xt(e,O),g!==null&&(g.f&N)!==0&&(g.f&(ne|re))===0&&(j===null?Ir([e]):j.push(e)),!r.is_fork&&ht.size>0&&!Kt&&Er()}return t}function Er(){Kt=!1;var e=oe;Xe(!0);const t=Array.from(ht);try{for(const n of t)(n.f&N)!==0&&A(n,W),Le(n)&&De(n)}finally{Xe(e)}ht.clear()}function xr(e,t=1){var n=c(e),r=t===1?n++:n--;return E(e,n),r}function Ae(e){E(e,e.v+1)}function Xt(e,t){var n=e.reactions;if(n!==null)for(var r=n.length,i=0;i<r;i++){var s=n[i],l=s.f,o=(l&O)===0;if(o&&A(s,t),(l&x)!==0){var f=s;D?.delete(f),(l&ue)===0&&(l&q&&(s.f|=ue),Xt(f,W))}else o&&((l&V)!==0&&K!==null&&K.add(s),$e(s))}}function Ee(e){if(typeof e!="object"||e===null||ot in e)return e;const t=At(e);if(t!==Yn&&t!==Jn)return e;var n=new Map,r=qn(e),i=$(0),s=ve,l=o=>{if(ve===s)return o();var f=v,a=ve;S(null),_n(s);var d=o();return S(f),_n(a),d};return r&&n.set("length",$(e.length)),new Proxy(e,{defineProperty(o,f,a){(!("value"in a)||a.configurable===!1||a.enumerable===!1||a.writable===!1)&&nr();var d=n.get(f);return d===void 0?d=l(()=>{var _=$(a.value);return n.set(f,_),_}):E(d,a.value,!0),!0},deleteProperty(o,f){var a=n.get(f);if(a===void 0){if(f in o){const d=l(()=>$(T));n.set(f,d),Ae(i)}}else E(a,T),Ae(i);return!0},get(o,f,a){if(f===ot)return e;var d=n.get(f),_=f in o;if(d===void 0&&(!_||ge(o,f)?.writable)&&(d=l(()=>{var h=Ee(_?o[f]:T),y=$(h);return y}),n.set(f,d)),d!==void 0){var u=c(d);return u===T?void 0:u}return Reflect.get(o,f,a)},getOwnPropertyDescriptor(o,f){var a=Reflect.getOwnPropertyDescriptor(o,f);if(a&&"value"in a){var d=n.get(f);d&&(a.value=c(d))}else if(a===void 0){var _=n.get(f),u=_?.v;if(_!==void 0&&u!==T)return{enumerable:!0,configurable:!0,value:u,writable:!0}}return a},has(o,f){if(f===ot)return!0;var a=n.get(f),d=a!==void 0&&a.v!==T||Reflect.has(o,f);if(a!==void 0||g!==null&&(!d||ge(o,f)?.writable)){a===void 0&&(a=l(()=>{var u=d?Ee(o[f]):T,h=$(u);return h}),n.set(f,a));var _=c(a);if(_===T)return!1}return d},set(o,f,a,d){var _=n.get(f),u=f in o;if(r&&f==="length")for(var h=a;h<_.v;h+=1){var y=n.get(h+"");y!==void 0?E(y,T):h in o&&(y=l(()=>$(T)),n.set(h+"",y))}if(_===void 0)(!u||ge(o,f)?.writable)&&(_=l(()=>$(void 0)),E(_,Ee(a)),n.set(f,_));else{u=_.v!==T;var I=l(()=>Ee(a));E(_,I)}var ee=Reflect.getOwnPropertyDescriptor(o,f);if(ee?.set&&ee.set.call(d,a),!u){if(r&&typeof f=="string"){var Te=n.get("length"),Me=Number(f);Number.isInteger(Me)&&Me>=Te.v&&E(Te,Me+1)}Ae(i)}return!0},ownKeys(o){c(i);var f=Reflect.ownKeys(o).filter(_=>{var u=n.get(_);return u===void 0||u.v!==T});for(var[a,d]of n)d.v!==T&&!(a in o)&&f.push(a);return f},setPrototypeOf(){rr()}})}var Zt,Qt,en,tn;function _t(){if(Zt===void 0){Zt=window,Qt=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;en=ge(t,"firstChild").get,tn=ge(t,"nextSibling").get,Ot(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),Ot(n)&&(n.__t=void 0)}}function Oe(e=""){return document.createTextNode(e)}function Ce(e){return en.call(e)}function X(e){return tn.call(e)}function nn(e,t){if(!m)return Ce(e);var n=Ce(w);return n===null&&(n=w.appendChild(Oe())),z(n),n}function Tr(e,t=!1){if(!m){var n=Ce(e);return n instanceof Comment&&n.data===""?X(n):n}if(t&&w?.nodeType!==Dt){var r=Oe();return w?.before(r),z(r),r}return w}function Z(e,t=1,n=!1){let r=m?w:e;for(var i;t--;)i=r,r=X(r);if(!m)return r;if(n&&r?.nodeType!==Dt){var s=Oe();return r===null?i?.after(s):r.before(s),z(s),s}return z(r),r}function Sr(e){e.textContent=""}function vt(e){var t=v,n=g;S(null),M(null);try{return e()}finally{S(t),M(n)}}function Nr(e){g===null&&(v===null&&Qn(),Zn()),_e&&Xn()}function kr(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function Y(e,t,n){var r=g;r!==null&&(r.f&ie)!==0&&(e|=ie);var i={ctx:L,deps:null,nodes_start:null,nodes_end:null,f:e|O|q,first:null,fn:t,last:null,next:null,parent:r,b:r&&r.b,prev:null,teardown:null,transitions:null,wv:0,ac:null};if(n)try{De(i),i.f|=Be}catch(o){throw U(i),o}else t!==null&&$e(i);var s=i;if(n&&s.deps===null&&s.teardown===null&&s.nodes_start===null&&s.first===s.last&&(s.f&ae)===0&&(s=s.first,(e&V)!==0&&(e&Ue)!==0&&s!==null&&(s.f|=Ue)),s!==null&&(s.parent=r,r!==null&&kr(s,r),v!==null&&(v.f&x)!==0&&(e&re)===0)){var l=v;(l.effects??=[]).push(s)}return i}function ze(){return v!==null&&!J}function rn(e){const t=Y(it,null,!1);return A(t,N),t.teardown=e,t}function Ar(e){Nr();var t=g.f,n=!v&&(t&ne)!==0&&(t&Be)===0;if(n){var r=L;(r.e??=[]).push(e)}else return sn(e)}function sn(e){return Y(rt|Wn,e,!1)}function Or(e){B.ensure();const t=Y(re|ae,e,!0);return()=>{U(t)}}function Cr(e){B.ensure();const t=Y(re|ae,e,!0);return(n={})=>new Promise(r=>{n.outro?Ke(t,()=>{U(t),r(void 0)}):(U(t),r(void 0))})}function Rr(e){return Y(rt,e,!1)}function Lr(e){return Y(lt|ae,e,!0)}function ln(e,t=0){return Y(it|t,e,!0)}function de(e,t=[],n=[],r=[]){yr(r,t,n,i=>{Y(it,()=>e(...i.map(c)),!0)})}function Dr(e,t=0){var n=Y(V|t,e,!0);return n}function he(e){return Y(ne|ae,e,!0)}function on(e){var t=e.teardown;if(t!==null){const n=_e,r=v;cn(!0),S(null);try{t.call(null)}finally{cn(n),S(r)}}}function fn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){const i=n.ac;i!==null&&vt(()=>{i.abort(ye)});var r=n.next;(n.f&re)!==0?n.parent=null:U(n,t),n=r}}function Pr(e){for(var t=e.first;t!==null;){var n=t.next;(t.f&ne)===0&&U(t),t=n}}function U(e,t=!0){var n=!1;(t||(e.f&Lt)!==0)&&e.nodes_start!==null&&e.nodes_end!==null&&(Mr(e.nodes_start,e.nodes_end),n=!0),fn(e,t&&!n),Ze(e,0),A(e,G);var r=e.transitions;if(r!==null)for(const s of r)s.stop();on(e);var i=e.parent;i!==null&&i.first!==null&&an(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes_start=e.nodes_end=e.ac=null}function Mr(e,t){for(;e!==null;){var n=e===t?null:X(e);e.remove(),e=n}}function an(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function Ke(e,t,n=!0){var r=[];un(e,r,!0),jr(r,()=>{n&&U(e),t&&t()})}function jr(e,t){var n=e.length;if(n>0){var r=()=>--n||t();for(var i of e)i.out(r)}else t()}function un(e,t,n){if((e.f&ie)===0){if(e.f^=ie,e.transitions!==null)for(const l of e.transitions)(l.is_global||n)&&t.push(l);for(var r=e.first;r!==null;){var i=r.next,s=(r.f&Ue)!==0||(r.f&ne)!==0&&(e.f&V)!==0;un(r,t,s?n:!1),r=i}}}function Fr(e,t){for(var n=e.nodes_start,r=e.nodes_end;n!==null;){var i=n===r?null:X(n);t.append(n),n=i}}let oe=!1;function Xe(e){oe=e}let _e=!1;function cn(e){_e=e}let v=null,J=!1;function S(e){v=e}let g=null;function M(e){g=e}let Q=null;function dn(e){v!==null&&(Q===null?Q=[e]:Q.push(e))}let k=null,C=0,j=null;function Ir(e){j=e}let hn=1,Re=0,ve=Re;function _n(e){ve=e}function vn(){return++hn}function Le(e){var t=e.f;if((t&O)!==0)return!0;if(t&x&&(e.f&=~ue),(t&W)!==0){var n=e.deps;if(n!==null)for(var r=n.length,i=0;i<r;i++){var s=n[i];if(Le(s)&&zt(s),s.wv>e.wv)return!0}(t&q)!==0&&D===null&&A(e,N)}return!1}function pn(e,t,n=!0){var r=e.reactions;if(r!==null&&!Q?.includes(e))for(var i=0;i<r.length;i++){var s=r[i];(s.f&x)!==0?pn(s,t,!1):t===s&&(n?A(s,O):(s.f&N)!==0&&A(s,W),$e(s))}}function gn(e){var t=k,n=C,r=j,i=v,s=Q,l=L,o=J,f=ve,a=e.f;k=null,C=0,j=null,v=(a&(ne|re))===0?e:null,Q=null,me(e.ctx),J=!1,ve=++Re,e.ac!==null&&(vt(()=>{e.ac.abort(ye)}),e.ac=null);try{e.f|=st;var d=e.fn,_=d(),u=e.deps;if(k!==null){var h;if(Ze(e,C),u!==null&&C>0)for(u.length=C+k.length,h=0;h<k.length;h++)u[C+h]=k[h];else e.deps=u=k;if(oe&&ze()&&(e.f&q)!==0)for(h=C;h<u.length;h++)(u[h].reactions??=[]).push(e)}else u!==null&&C<u.length&&(Ze(e,C),u.length=C);if(qt()&&j!==null&&!J&&u!==null&&(e.f&(x|W|O))===0)for(h=0;h<j.length;h++)pn(j[h],e);return i!==null&&i!==e&&(Re++,j!==null&&(r===null?r=j:r.push(...j))),(e.f&se)!==0&&(e.f^=se),_}catch(y){return Ut(y)}finally{e.f^=st,k=t,C=n,j=r,v=i,Q=s,me(l),J=o,ve=f}}function qr(e,t){let n=t.reactions;if(n!==null){var r=Bn.call(n,e);if(r!==-1){var i=n.length-1;i===0?n=t.reactions=null:(n[r]=n[i],n.pop())}}n===null&&(t.f&x)!==0&&(k===null||!k.includes(t))&&(A(t,W),(t.f&q)!==0&&(t.f^=q,t.f&=~ue),Gt(t),Ze(t,0))}function Ze(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)qr(e,n[r])}function De(e){var t=e.f;if((t&G)===0){A(e,N);var n=g,r=oe;g=e,oe=!0;try{(t&V)!==0?Pr(e):fn(e),on(e);var i=gn(e);e.teardown=typeof i=="function"?i:null,e.wv=hn;var s;nt&&cr&&(e.f&O)!==0&&e.deps}finally{oe=r,g=n}}}function c(e){var t=e.f,n=(t&x)!==0;if(v!==null&&!J){var r=g!==null&&(g.f&G)!==0;if(!r&&!Q?.includes(e)){var i=v.deps;if((v.f&st)!==0)e.rv<Re&&(e.rv=Re,k===null&&i!==null&&i[C]===e?C++:k===null?k=[e]:k.includes(e)||k.push(e));else{(v.deps??=[]).push(e);var s=e.reactions;s===null?e.reactions=[v]:s.includes(v)||s.push(v)}}}if(_e){if(le.has(e))return le.get(e);if(n){var l=e,o=l.v;return((l.f&N)===0&&l.reactions!==null||wn(l))&&(o=dt(l)),le.set(l,o),o}}else n&&!D?.has(e)&&(l=e,Le(l)&&zt(l),oe&&ze()&&(l.f&q)===0&&yn(l));if(D?.has(e))return D.get(e);if((e.f&se)!==0)throw e.v;return e.v}function yn(e){if(e.deps!==null){e.f^=q;for(const t of e.deps)(t.reactions??=[]).push(e),(t.f&x)!==0&&(t.f&q)===0&&yn(t)}}function wn(e){if(e.v===T)return!0;if(e.deps===null)return!1;for(const t of e.deps)if(le.has(t)||(t.f&x)!==0&&wn(t))return!0;return!1}function Br(e){var t=J;try{return J=!0,e()}finally{J=t}}const Ur=-7169;function A(e,t){e.f=e.f&Ur|t}const mn=new Set,pt=new Set;function Hr(e,t,n,r={}){function i(s){if(r.capture||Pe.call(t,s),!s.cancelBubble)return vt(()=>n?.call(this,s))}return e.startsWith("pointer")||e.startsWith("touch")||e==="wheel"?Ye(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function Qe(e,t,n,r,i){var s={capture:r,passive:i},l=Hr(e,t,n,s);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&rn(()=>{t.removeEventListener(e,l,s)})}function Yr(e){for(var t=0;t<e.length;t++)mn.add(e[t]);for(var n of pt)n(e)}let bn=null;function Pe(e){var t=this,n=t.ownerDocument,r=e.type,i=e.composedPath?.()||[],s=i[0]||e.target;bn=e;var l=0,o=bn===e&&e.__root;if(o){var f=i.indexOf(o);if(f!==-1&&(t===document||t===window)){e.__root=t;return}var a=i.indexOf(t);if(a===-1)return;f<=a&&(l=f)}if(s=i[l]||e.target,s!==t){Ie(e,"currentTarget",{configurable:!0,get(){return s||n}});var d=v,_=g;S(null),M(null);try{for(var u,h=[];s!==null;){var y=s.assignedSlot||s.parentNode||s.host||null;try{var I=s["__"+r];I!=null&&(!s.disabled||e.target===s)&&I.call(s,e)}catch(ee){u?h.push(ee):u=ee}if(e.cancelBubble||y===t||y===null)break;s=y}if(u){for(let ee of h)queueMicrotask(()=>{throw ee});throw u}}finally{e.__root=t,delete e.currentTarget,S(d),M(_)}}}function Jr(e){var t=document.createElement("template");return t.innerHTML=e.replaceAll("<!>","<!---->"),t.content}function gt(e,t){var n=g;n.nodes_start===null&&(n.nodes_start=e,n.nodes_end=t)}function Vr(e,t){var n=(t&Fn)!==0,r,i=!e.startsWith("<!>");return()=>{if(m)return gt(w,null),w;r===void 0&&(r=Jr(i?e:"<!>"+e));var s=n||Qt?document.importNode(r,!0):r.cloneNode(!0);{var l=Ce(s),o=s.lastChild;gt(l,o)}return s}}function $n(e,t){if(m){var n=g;((n.f&Be)===0||n.nodes_end===null)&&(n.nodes_end=w),Pt();return}e!==null&&e.before(t)}const Wr=["touchstart","touchmove"];function Gr(e){return Wr.includes(e)}function En(e,t){return xn(e,t)}function zr(e,t){_t(),t.intro=t.intro??!1;const n=t.target,r=m,i=w;try{for(var s=Ce(n);s&&(s.nodeType!==He||s.data!==St);)s=X(s);if(!s)throw Se;we(!0),z(s);const l=xn(e,{...t,anchor:s});return we(!1),l}catch(l){if(l instanceof Error&&l.message.split(`
2
- `).some(o=>o.startsWith("https://svelte.dev/e/")))throw l;return l!==Se&&console.warn("Failed to hydrate: ",l),t.recover===!1&&tr(),_t(),Sr(n),we(!1),En(e,t)}finally{we(r),z(i)}}const xe=new Map;function xn(e,{target:t,anchor:n,props:r={},events:i,context:s,intro:l=!0}){_t();var o=new Set,f=_=>{for(var u=0;u<_.length;u++){var h=_[u];if(!o.has(h)){o.add(h);var y=Gr(h);t.addEventListener(h,Pe,{passive:y});var I=xe.get(h);I===void 0?(document.addEventListener(h,Pe,{passive:y}),xe.set(h,1)):xe.set(h,I+1)}}};f(Un(mn)),pt.add(f);var a=void 0,d=Cr(()=>{var _=n??t.appendChild(Oe());return pr(_,{pending:()=>{}},u=>{if(s){Ft({});var h=L;h.c=s}if(i&&(r.$$events=i),m&&gt(u,null),a=e(u,r)||{},m&&(g.nodes_end=w,w===null||w.nodeType!==He||w.data!==kt))throw ft(),Se;s&&It()}),()=>{for(var u of o){t.removeEventListener(u,Pe);var h=xe.get(u);--h===0?(document.removeEventListener(u,Pe),xe.delete(u)):xe.set(u,h)}pt.delete(f),_!==n&&_.parentNode?.removeChild(_)}});return yt.set(a,d),a}let yt=new WeakMap;function Kr(e,t){const n=yt.get(e);return n?(yt.delete(e),n(t)):Promise.resolve()}function Xr(e,t){Rr(()=>{var n=e.getRootNode(),r=n.host?n:n.head??n.ownerDocument.head;if(!r.querySelector("#"+t.hash)){const i=document.createElement("style");i.id=t.hash,i.textContent=t.code,r.appendChild(i)}})}function Zr(e,t){return e==null?null:String(e)}function wt(e,t,n,r){var i=e.__style;if(m||i!==t){var s=Zr(t);(!m||s!==e.getAttribute("style"))&&(s==null?e.removeAttribute("style"):e.style.cssText=s),e.__style=t}return r}const Qr=Symbol("is custom element"),ei=Symbol("is html");function ti(e,t,n,r){var i=ni(e);m&&(i[t]=e.getAttribute(t),t==="src"||t==="srcset"||t==="href"&&e.nodeName==="LINK")||i[t]!==(i[t]=n)&&(t==="loading"&&(e[zn]=n),n==null?e.removeAttribute(t):typeof n!="string"&&Tn(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function F(e,t,n){var r=v,i=g;let s=m;m&&we(!1),S(null),M(null);try{t!=="style"&&(mt.has(e.getAttribute("is")||e.nodeName)||!customElements||customElements.get(e.getAttribute("is")||e.tagName.toLowerCase())?Tn(e).includes(t):n&&typeof n=="object")?e[t]=n:ti(e,t,n==null?n:String(n))}finally{S(r),M(i),s&&we(!0)}}function ni(e){return e.__attributes??={[Qr]:e.nodeName.includes("-"),[ei]:e.namespaceURI===In}}var mt=new Map;function Tn(e){var t=e.getAttribute("is")||e.nodeName,n=mt.get(t);if(n)return n;mt.set(t,n=[]);for(var r,i=e,s=Element.prototype;s!==i;){r=Hn(i);for(var l in r)r[l].set&&n.push(l);i=At(i)}return n}function Sn(e,t,n,r){var i=r,s=!0,l=()=>(s&&(s=!1,i=r),i),o;o=e[t],o===void 0&&r!==void 0&&(o=l());var f;f=()=>{var u=e[t];return u===void 0?l():(s=!0,u)};var a=!1,d=ct(()=>(a=!1,f())),_=g;return(function(u,h){if(arguments.length>0){const y=h?c(d):u;return E(d,y),a=!0,i!==void 0&&(i=y),u}return _e&&a||(_.f&G)!==0?d.v:c(d)})}function ri(e){return new ii(e)}class ii{#t;#e;constructor(t){var n=new Map,r=(s,l)=>{var o=$r(l,!1,!1);return n.set(s,o),o};const i=new Proxy({...t.props||{},$$events:{}},{get(s,l){return c(n.get(l)??r(l,Reflect.get(s,l)))},has(s,l){return l===Gn?!0:(c(n.get(l)??r(l,Reflect.get(s,l))),Reflect.has(s,l))},set(s,l,o){return E(n.get(l)??r(l,o),o),Reflect.set(s,l,o)}});this.#e=(t.hydrate?zr:En)(t.component,{target:t.target,anchor:t.anchor,props:i,context:t.context,intro:t.intro??!1,recover:t.recover}),(!t?.props?.$$host||t.sync===!1)&&ut(),this.#t=i.$$events;for(const s of Object.keys(this.#e))s==="$set"||s==="$destroy"||s==="$on"||Ie(this,s,{get(){return this.#e[s]},set(l){this.#e[s]=l},enumerable:!0});this.#e.$set=s=>{Object.assign(i,s)},this.#e.$destroy=()=>{Kr(this.#e)}}$set(t){this.#e.$set(t)}$on(t,n){this.#t[t]=this.#t[t]||[];const r=(...i)=>n.call(this,...i);return this.#t[t].push(r),()=>{this.#t[t]=this.#t[t].filter(i=>i!==r)}}$destroy(){this.#e.$destroy()}}let Nn;typeof HTMLElement=="function"&&(Nn=class extends HTMLElement{$$ctor;$$s;$$c;$$cn=!1;$$d={};$$r=!1;$$p_d={};$$l={};$$l_u=new Map;$$me;constructor(e,t,n){super(),this.$$ctor=e,this.$$s=t,n&&this.attachShadow({mode:"open"})}addEventListener(e,t,n){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const r=this.$$c.$on(e,t);this.$$l_u.set(t,r)}super.addEventListener(e,t,n)}removeEventListener(e,t,n){if(super.removeEventListener(e,t,n),this.$$c){const r=this.$$l_u.get(t);r&&(r(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(r){return i=>{const s=document.createElement("slot");r!=="default"&&(s.name=r),$n(i,s)}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},n=si(this);for(const r of this.$$s)r in n&&(r==="default"&&!this.$$d.children?(this.$$d.children=e(r),t.default=!0):t[r]=e(r));for(const r of this.attributes){const i=this.$$g_p(r.name);i in this.$$d||(this.$$d[i]=et(i,r.value,this.$$p_d,"toProp"))}for(const r in this.$$p_d)!(r in this.$$d)&&this[r]!==void 0&&(this.$$d[r]=this[r],delete this[r]);this.$$c=ri({component:this.$$ctor,target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$host:this}}),this.$$me=Or(()=>{ln(()=>{this.$$r=!0;for(const r of Fe(this.$$c)){if(!this.$$p_d[r]?.reflect)continue;this.$$d[r]=this.$$c[r];const i=et(r,this.$$d[r],this.$$p_d,"toAttribute");i==null?this.removeAttribute(this.$$p_d[r].attribute||r):this.setAttribute(this.$$p_d[r].attribute||r,i)}this.$$r=!1})});for(const r in this.$$l)for(const i of this.$$l[r]){const s=this.$$c.$on(r,i);this.$$l_u.set(i,s)}this.$$l={}}}attributeChangedCallback(e,t,n){this.$$r||(e=this.$$g_p(e),this.$$d[e]=et(e,n,this.$$p_d,"toProp"),this.$$c?.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$me(),this.$$c=void 0)})}$$g_p(e){return Fe(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function et(e,t,n,r){const i=n[e]?.type;if(t=i==="Boolean"&&typeof t!="boolean"?t!=null:t,!r||!n[e])return t;if(r==="toAttribute")switch(i){case"Object":case"Array":return t==null?null:JSON.stringify(t);case"Boolean":return t?"":null;case"Number":return t??null;default:return t}else switch(i){case"Object":case"Array":return t&&JSON.parse(t);case"Boolean":return t;case"Number":return t!=null?+t:t;default:return t}}function si(e){const t={};return e.childNodes.forEach(n=>{t[n.slot||"default"]=!0}),t}function li(e,t,n,r,i,s){let l=class extends Nn{constructor(){super(e,n,i),this.$$p_d=t}static get observedAttributes(){return Fe(t).map(o=>(t[o].attribute||o).toLowerCase())}};return Fe(t).forEach(o=>{Ie(l.prototype,o,{get(){return this.$$c&&o in this.$$c?this.$$c[o]:this.$$d[o]},set(f){f=et(o,f,t),this.$$d[o]=f;var a=this.$$c;if(a){var d=ge(a,o)?.get;d?a[o]=f:a.$set({[o]:f})}}})}),r.forEach(o=>{Ie(l.prototype,o,{get(){return this.$$c?.[o]}})}),e.element=l,l}const kn={version:"0.65.22"};var pe={},An;function oi(){if(An)return pe;An=1,Object.defineProperty(pe,"__esModule",{value:!0}),pe.LanguageTranslator=void 0,pe.getChildStyleToPass=e,pe.addComponent=t;function e(r,i){var s,l,o="";try{if(r&&i?.length&&(!((s=Object.keys(r))===null||s===void 0)&&s.length)&&(!((l=i?.filter(function(u){return Object.keys(r).includes(u.name)}))===null||l===void 0)&&l.length))for(var f=function(u){var h=i?.filter(function(y){return y.name===u&&y.defaultValue!==r[u]});h&&(o+="".concat(u,":").concat(r[u],";"))},a=0,d=Object.keys(r);a<d.length;a++){var _=d[a];f(_)}}catch(u){console.error("error getting child style to pass",u)}finally{return o}}function t(r){var i,s=((i=r?.repoName.split("/"))===null||i===void 0?void 0:i[1])||r?.repoName;if(!s)throw new Error("wrong componentPath "+r?.repoName);if(!r?.version)throw new Error("wrong version "+r?.version);var l=r?.iifePath||"main.iife.js";if(!document.getElementById(s+"-script"))try{var o=document.createElement("script");if(o.id=s+"-script",o.src="https://cdn.jsdelivr.net/npm/".concat(r.repoName,"@").concat(r.version,"/").concat(l),r?.local)o.src="".concat(r.local);else if(location.href.includes("localhost:6006")){var f=s.split("-")[0];o.src="http://localhost:6006/webcomponents/".concat(s.replace(f+"-",""),"/").concat(l)}document.head.appendChild(o)}catch(a){console.warn(a)}}var n=(function(){function r(i){if(this.lang="",!i?.dictionary)throw new Error("no dictionary provided");this.dictionary=i.dictionary,this.setLang(i?.lang)}return r.prototype.setLang=function(i){i||(i=r.getDefaultLang()),this.lang=i},r.prototype.translateWord=function(i,s){return r.getDictionaryWord(i,this.dictionary,s||this.lang)},r.prototype.translateDate=function(i,s,l){return r.formatDate(i,s,l||this.lang)},r.getDefaultLang=function(){var i,s,l,o="en";return navigator?.languages&&(!((l=(s=(i=navigator.languages[0])===null||i===void 0?void 0:i.split("-")[0])===null||s===void 0?void 0:s.toLowerCase())===null||l===void 0)&&l.length)&&(o=navigator.languages[0].split("-")[0].toLowerCase()),o},r.getDictionaryWord=function(i,s,l){var o;if(!i)throw new Error("no wordKey provided");if(!s)throw new Error("no dictionary provided");if(l&&(!((o=s[l])===null||o===void 0)&&o[i]))return s[l][i];var f="",a=r.getDefaultLang();if(!l||a!==l){var d=s?.[a];d?.[i]&&(f=d[i])}return f},r.formatDate=function(i,s,l){if(!i)throw new Error("no date provided");if(typeof i.getMonth!="function")throw new Error("wrong date format");var o=new Intl.DateTimeFormat(l||r.getDefaultLang(),s);return o.format(i)},r})();return pe.LanguageTranslator=n,pe}var On=oi(),fi=Vr('<div part="controller" id="controller" class="svelte-1swbd4i"><button>clear</button> <button>select</button> <button>draw</button> <button>undo</button> <button>redo</button> <button>save</button> <button>brush</button> <br/>load:<hb-input-file></hb-input-file> insert:<hb-input-file></hb-input-file></div> <div part="paper-container" id="paper-container" style="position:relative" class="svelte-1swbd4i"><hb-stylus-paper></hb-stylus-paper></div>',3);const ai={hash:"svelte-1swbd4i",code:'@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap");:host {font-family:"Roboto", sans-serif;position:absolute;width:100%;height:100%;display:block;display:grid;grid-template-areas:"header" "paper";grid-template-columns:1fr;grid-template-rows:auto 1fr;}#controller.svelte-1swbd4i {grid-area:header;}#paper-container.svelte-1swbd4i {grid-area:paper;background:green;}'};function Cn(e,t){Ft(t,!0),Xr(e,ai);let n=Sn(t,"id",7,""),r=Sn(t,"load_draw"),i=$("draw");Ee({});let s=$(""),l=$(""),o=$(0),f=$(void 0),a=$(!1),d=$(void 0),_=$(void 0),u=$(void 0),h=$(void 0),y=Wt(()=>(c(f)===0||c(f))&&c(f)<c(o)),I=Wt(()=>(c(o)||c(o)===0)&&c(a)&&(!c(f)||c(f)!==-1)&&(!c(h)||c(h)<c(o)&&(!c(f)||c(f)<c(h))));Ar(()=>{if(typeof r()=="string"&&r()?.length)try{r(JSON.parse(r()))}catch(p){console.error("error parsing json",p)}}),On.addComponent({repoName:"@htmlbricks/hb-stylus-paper",version:kn.version}),On.addComponent({repoName:"@htmlbricks/hb-input-file",version:kn.version});function ee(p,fe){var te="data:text/json;charset=utf-8,"+encodeURIComponent(JSON.stringify(p)),R=document.createElement("a");R.setAttribute("href",te),R.setAttribute("download",fe),document.body.appendChild(R),R.click(),R.remove()}function Te(p){E(i,p,!0)}function Me(){console.log("ch",c(o),c(f)),c(o)>=0&&(!c(f)||c(f)>-1)&&(E(f,c(f)||c(f)===0?c(f)-1:c(o)-1,!0),console.log("undo",c(o),c(f)))}function ui(){console.log(c(o),c(f)),(c(f)||c(f)===0)&&c(f)<=c(o)&&(xr(f),console.log("redo",c(o),c(f)))}function ci(p){c(a)||E(a,!0),console.log("h",p),E(o,p.index-1),p.start_index&&E(h,p.start_index,!0),E(f,void 0)}function di(){E(d,{name:"test",type:"json"},!0)}function hi(p){const fe=p.value?.name;if(fe){const te=new FileReader;te.readAsDataURL(p.value),te.onload=function(R){try{if(console.log("insert file",R.target,R.target?.result),R.target?.result){const yi=R.target.result.toString().split(";")[0].split("/")[1];E(_,{base64:R.target.result.toString(),type:yi,name:fe},!0)}}catch{console.error("error loading file")}},te.onerror=function(R){console.error("error reading file")}}}function _i(p){console.log("save",p),E(d,void 0),ee(p,p?.name+".json")}function vi(p){if(console.log("file",p),p.value?.name){const fe=new FileReader;fe.readAsText(p.value,"UTF-8"),fe.onload=function(te){if(te?.target?.result?.toString())try{r(JSON.parse(te.target.result.toString()))}catch{console.error("error loading file")}},fe.onerror=function(te){console.error("error reading file")}}}var pi={get id(){return n()},set id(p=""){n(p),ut()},get load_draw(){return r()},set load_draw(p){r(p),ut()}},Rn=fi(),bt=Tr(Rn),Ln=nn(bt);Ln.__click=()=>Te("eraser");var Dn=Z(Ln,2);Dn.__click=()=>Te("select");var Pn=Z(Dn,2);Pn.__click=()=>Te("draw");var $t=Z(Pn,2);$t.__click=()=>Me();var Et=Z($t,2);Et.__click=()=>ui();var xt=Z(Et,2);xt.__click=()=>di();var Mn=Z(xt,2),je=Z(Mn,4);F(je,"id","loadfile"),wt(je,c(l)),F(je,"schemaentry",JSON.stringify({label:"ciao",id:"xxxxxxx"}));var tt=Z(je,2);F(tt,"id","insertfile"),wt(tt,c(l)),F(tt,"schemaentry",JSON.stringify({label:"ciao"})),Mt(bt);var jn=Z(bt,2),H=nn(jn);return F(H,"id","stylus-paper"),de(()=>F(H,"goto",c(f))),wt(H,c(s)),F(H,"background_color","green"),de(()=>F(H,"mode",c(i))),de(()=>F(H,"save_as",c(d)?JSON.stringify(c(d)):"")),de(()=>F(H,"load_draw",r()?JSON.stringify(r()):null)),de(()=>F(H,"insert_image",c(_)?JSON.stringify(c(_)):null)),de(()=>F(H,"insert_text",c(u)?JSON.stringify(c(u)):null)),Mt(jn),de(()=>{$t.disabled=!c(I),Et.disabled=!c(y),xt.disabled=!c(I),Mn.disabled=c(i)!=="draw"}),Qe("setVal",je,p=>vi(p.detail)),Qe("setVal",tt,p=>hi(p.detail)),Qe("historyIndex",H,p=>ci(p.detail)),Qe("save",H,p=>_i(p.detail)),$n(e,Rn),It(pi)}Yr(["click"]),customElements.define("hb-stylus-notebook",li(Cn,{id:{},load_draw:{}},[],[],!0)),Tt.Component=Cn,Object.defineProperty(Tt,Symbol.toStringTag,{value:"Module"})})(this["stylus-notebook"]=this["stylus-notebook"]||{});
1
+ (function(xt){"use strict";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add("5");const jn=2,Tt="[",Nt="[!",kt="]",xe={},x=Symbol(),In="http://www.w3.org/1999/xhtml",tt=!1;var Fn=Array.isArray,qn=Array.prototype.indexOf,Bn=Array.from,Me=Object.keys,je=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,Un=Object.getOwnPropertyDescriptors,Hn=Object.prototype,Yn=Array.prototype,St=Object.getPrototypeOf,At=Object.isExtensible;function Jn(e){for(var t=0;t<e.length;t++)e[t]()}function Ot(){var e,t,n=new Promise((r,i)=>{e=r,t=i});return{promise:n,resolve:e,reject:t}}const E=2,nt=4,rt=8,V=16,ne=32,re=64,Ie=128,q=512,k=1024,O=2048,W=4096,ie=8192,G=16384,Fe=32768,qe=65536,Ct=1<<17,Rt=1<<18,ae=1<<19,Vn=1<<20,ue=32768,it=1<<21,st=1<<22,se=1<<23,ot=Symbol("$state"),Wn=Symbol("legacy props"),Gn=Symbol(""),we=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"},Lt=3,Be=8;function zn(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Kn(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function Xn(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function Zn(e){throw new Error("https://svelte.dev/e/effect_orphan")}function Qn(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function er(){throw new Error("https://svelte.dev/e/hydration_failed")}function tr(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function nr(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function rr(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function ir(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}function lt(e){console.warn("https://svelte.dev/e/hydration_mismatch")}function sr(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}let y=!1;function me(e){y=e}let m;function z(e){if(e===null)throw lt(),xe;return m=e}function Dt(){return z(X(m))}function Pt(e){if(y){if(X(m)!==null)throw lt(),xe;m=e}}function or(e=1){if(y){for(var t=e,n=m;t--;)n=X(n);m=n}}function lr(e=!0){for(var t=0,n=m;;){if(n.nodeType===Be){var r=n.data;if(r===kt){if(t===0)return n;t-=1}else(r===Tt||r===Nt)&&(t+=1)}var i=X(n);e&&n.remove(),n=i}}function Mt(e){return e===this.v}function fr(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function ar(e){return!fr(e,this.v)}let ur=!1,D=null;function ye(e){D=e}function jt(e,t=!1,n){D={p:D,i:!1,c:null,e:null,s:e,x:null,l:null}}function It(e){var t=D,n=t.e;if(n!==null){t.e=null;for(var r of n)rn(r)}return e!==void 0&&(t.x=e),t.i=!0,D=t.p,e??{}}function Ft(){return!0}let ce=[];function qt(){var e=ce;ce=[],Jn(e)}function Ue(e){if(ce.length===0&&!Te){var t=ce;queueMicrotask(()=>{t===ce&&qt()})}ce.push(e)}function cr(){for(;ce.length>0;)qt()}function Bt(e){var t=g;if(t===null)return v.f|=se,e;if((t.f&Fe)===0){if((t.f&Ie)===0)throw e;t.b.error(e)}else be(e,t)}function be(e,t){for(;t!==null;){if((t.f&Ie)!==0)try{t.b.error(e);return}catch(n){e=n}t=t.parent}throw e}const He=new Set;let b=null,P=null,M=[],Ye=null,ft=!1,Te=!1;class B{committed=!1;current=new Map;previous=new Map;#t=new Set;#e=new Set;#f=0;#s=0;#a=null;#o=[];#i=[];skipped_effects=new Set;is_fork=!1;is_deferred(){return this.is_fork||this.#s>0}process(t){M=[],this.apply();var n={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const r of t)this.#n(r,n);this.is_fork||this.#u(),this.is_deferred()?(this.#r(n.effects),this.#r(n.render_effects),this.#r(n.block_effects)):(b=null,Ht(n.render_effects),Ht(n.effects),this.#a?.resolve()),P=null}#n(t,n){t.f^=k;for(var r=t.first;r!==null;){var i=r.f,s=(i&(ne|re))!==0,o=s&&(i&k)!==0,l=o||(i&ie)!==0||this.skipped_effects.has(r);if((r.f&Ie)!==0&&r.b?.is_pending()&&(n={parent:n,effect:r,effects:[],render_effects:[],block_effects:[]}),!l&&r.fn!==null){s?r.f^=k:(i&nt)!==0?n.effects.push(r):Re(r)&&((r.f&V)!==0&&n.block_effects.push(r),Le(r));var f=r.first;if(f!==null){r=f;continue}}var a=r.parent;for(r=r.next;r===null&&a!==null;)a===n.effect&&(this.#r(n.effects),this.#r(n.render_effects),this.#r(n.block_effects),n=n.parent),r=a.next,a=a.parent}}#r(t){for(const n of t)((n.f&O)!==0?this.#o:this.#i).push(n),this.#l(n.deps),A(n,k)}#l(t){if(t!==null)for(const n of t)(n.f&E)===0||(n.f&ue)===0||(n.f^=ue,this.#l(n.deps))}capture(t,n){this.previous.has(t)||this.previous.set(t,n),(t.f&se)===0&&(this.current.set(t,t.v),P?.set(t,t.v))}activate(){b=this,this.apply()}deactivate(){b===this&&(b=null,P=null)}flush(){if(this.activate(),M.length>0){if(Ut(),b!==null&&b!==this)return}else this.#f===0&&this.process([]);this.deactivate()}discard(){for(const t of this.#e)t(this);this.#e.clear()}#u(){if(this.#s===0){for(const t of this.#t)t();this.#t.clear()}this.#f===0&&this.#c()}#c(){if(He.size>1){this.previous.clear();var t=P,n=!0,r={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const s of He){if(s===this){n=!1;continue}const o=[];for(const[f,a]of this.current){if(s.current.has(f))if(n&&a!==s.current.get(f))s.current.set(f,a);else continue;o.push(f)}if(o.length===0)continue;const l=[...s.current.keys()].filter(f=>!this.current.has(f));if(l.length>0){var i=M;M=[];const f=new Set,a=new Map;for(const c of o)Yt(c,l,f,a);if(M.length>0){b=s,s.apply();for(const c of M)s.#n(c,r);s.deactivate()}M=i}}b=null,P=t}this.committed=!0,He.delete(this)}increment(t){this.#f+=1,t&&(this.#s+=1)}decrement(t){this.#f-=1,t&&(this.#s-=1),this.revive()}revive(){for(const t of this.#o)A(t,O),$e(t);for(const t of this.#i)A(t,W),$e(t);this.#o=[],this.#i=[],this.flush()}oncommit(t){this.#t.add(t)}ondiscard(t){this.#e.add(t)}settled(){return(this.#a??=Ot()).promise}static ensure(){if(b===null){const t=b=new B;He.add(b),Te||B.enqueue(()=>{b===t&&t.flush()})}return b}static enqueue(t){Ue(t)}apply(){}}function at(e){var t=Te;Te=!0;try{for(var n;;){if(cr(),M.length===0&&(b?.flush(),M.length===0))return Ye=null,n;Ut()}}finally{Te=t}}function Ut(){var e=le;ft=!0;var t=null;try{var n=0;for(ze(!0);M.length>0;){var r=B.ensure();if(n++>1e3){var i,s;dr()}r.process(M),oe.clear()}}finally{ft=!1,ze(e),Ye=null}}function dr(){try{Qn()}catch(e){be(e,Ye)}}let K=null;function Ht(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if((r.f&(G|ie))===0&&Re(r)&&(K=new Set,Le(r),r.deps===null&&r.first===null&&r.nodes_start===null&&(r.teardown===null&&r.ac===null?fn(r):r.fn=null),K?.size>0)){oe.clear();for(const i of K){if((i.f&(G|ie))!==0)continue;const s=[i];let o=i.parent;for(;o!==null;)K.has(o)&&(K.delete(o),s.push(o)),o=o.parent;for(let l=s.length-1;l>=0;l--){const f=s[l];(f.f&(G|ie))===0&&Le(f)}}K.clear()}}K=null}}function Yt(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(const i of e.reactions){const s=i.f;(s&E)!==0?Yt(i,t,n,r):(s&(st|V))!==0&&(s&O)===0&&Jt(i,t,r)&&(A(i,O),$e(i))}}function Jt(e,t,n){const r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(const i of e.deps){if(t.includes(i))return!0;if((i.f&E)!==0&&Jt(i,t,n))return n.set(i,!0),!0}return n.set(e,!1),!1}function $e(e){for(var t=Ye=e;t.parent!==null;){t=t.parent;var n=t.f;if(ft&&t===g&&(n&V)!==0&&(n&Rt)===0)return;if((n&(re|ne))!==0){if((n&k)===0)return;t.f^=k}}M.push(t)}function hr(e){let t=0,n=Ne(0),r;return()=>{We()&&(d(n),sn(()=>(t===0&&(r=qr(()=>e(()=>ke(n)))),t+=1,()=>{Ue(()=>{t-=1,t===0&&(r?.(),r=void 0,ke(n))})})))}}var _r=qe|ae|Ie;function vr(e,t,n){new pr(e,t,n)}class pr{parent;#t=!1;#e;#f=y?m:null;#s;#a;#o;#i=null;#n=null;#r=null;#l=null;#u=null;#c=0;#d=0;#_=!1;#h=null;#m=hr(()=>(this.#h=Ne(this.#c),()=>{this.#h=null}));constructor(t,n,r){this.#e=t,this.#s=n,this.#a=r,this.parent=g.b,this.#t=!!this.#s.pending,this.#o=Lr(()=>{if(g.b=this,y){const s=this.#f;Dt(),s.nodeType===Be&&s.data===Nt?this.#b():this.#y()}else{var i=this.#g();try{this.#i=he(()=>r(i))}catch(s){this.error(s)}this.#d>0?this.#p():this.#t=!1}return()=>{this.#u?.remove()}},_r),y&&(this.#e=m)}#y(){try{this.#i=he(()=>this.#a(this.#e))}catch(t){this.error(t)}this.#t=!1}#b(){const t=this.#s.pending;t&&(this.#n=he(()=>t(this.#e)),B.enqueue(()=>{var n=this.#g();this.#i=this.#v(()=>(B.ensure(),he(()=>this.#a(n)))),this.#d>0?this.#p():(Ge(this.#n,()=>{this.#n=null}),this.#t=!1)}))}#g(){var t=this.#e;return this.#t&&(this.#u=Ae(),this.#e.before(this.#u),t=this.#u),t}is_pending(){return this.#t||!!this.parent&&this.parent.is_pending()}has_pending_snippet(){return!!this.#s.pending}#v(t){var n=g,r=v,i=D;j(this.#o),N(this.#o),ye(this.#o.ctx);try{return t()}catch(s){return Bt(s),null}finally{j(n),N(r),ye(i)}}#p(){const t=this.#s.pending;this.#i!==null&&(this.#l=document.createDocumentFragment(),this.#l.append(this.#u),jr(this.#i,this.#l)),this.#n===null&&(this.#n=he(()=>t(this.#e)))}#w(t){if(!this.has_pending_snippet()){this.parent&&this.parent.#w(t);return}this.#d+=t,this.#d===0&&(this.#t=!1,this.#n&&Ge(this.#n,()=>{this.#n=null}),this.#l&&(this.#e.before(this.#l),this.#l=null))}update_pending_count(t){this.#w(t),this.#c+=t,this.#h&&Ve(this.#h,this.#c)}get_effect_pending(){return this.#m(),d(this.#h)}error(t){var n=this.#s.onerror;let r=this.#s.failed;if(this.#_||!n&&!r)throw t;this.#i&&(U(this.#i),this.#i=null),this.#n&&(U(this.#n),this.#n=null),this.#r&&(U(this.#r),this.#r=null),y&&(z(this.#f),or(),z(lr()));var i=!1,s=!1;const o=()=>{if(i){sr();return}i=!0,s&&ir(),B.ensure(),this.#c=0,this.#r!==null&&Ge(this.#r,()=>{this.#r=null}),this.#t=this.has_pending_snippet(),this.#i=this.#v(()=>(this.#_=!1,he(()=>this.#a(this.#e)))),this.#d>0?this.#p():this.#t=!1};var l=v;try{N(null),s=!0,n?.(t,o),s=!1}catch(f){be(f,this.#o&&this.#o.parent)}finally{N(l)}r&&Ue(()=>{this.#r=this.#v(()=>{B.ensure(),this.#_=!0;try{return he(()=>{r(this.#e,()=>t,()=>o)})}catch(f){return be(f,this.#o.parent),null}finally{this.#_=!1}})})}}function gr(e,t,n,r){const i=ut;if(n.length===0&&e.length===0){r(t.map(i));return}var s=b,o=g,l=wr();function f(){Promise.all(n.map(a=>mr(a))).then(a=>{l();try{r([...t.map(i),...a])}catch(c){(o.f&G)===0&&be(c,o)}s?.deactivate(),Je()}).catch(a=>{be(a,o)})}e.length>0?Promise.all(e).then(()=>{l();try{return f()}finally{s?.deactivate(),Je()}}):f()}function wr(){var e=g,t=v,n=D,r=b;return function(s=!0){j(e),N(t),ye(n),s&&r?.activate()}}function Je(){j(null),N(null),ye(null)}function ut(e){var t=E|O,n=v!==null&&(v.f&E)!==0?v:null;return g!==null&&(g.f|=ae),{ctx:D,deps:null,effects:null,equals:Mt,f:t,fn:e,reactions:null,rv:0,v:x,wv:0,parent:n??g,ac:null}}function mr(e,t){let n=g;n===null&&zn();var r=n.b,i=void 0,s=Ne(x),o=!v,l=new Map;return Rr(()=>{var f=Ot();i=f.promise;try{Promise.resolve(e()).then(f.resolve,f.reject).then(()=>{a===b&&a.committed&&a.deactivate(),Je()})}catch(u){f.reject(u),Je()}var a=b;if(o){var c=!r.is_pending();r.update_pending_count(1),a.increment(c),l.get(a)?.reject(we),l.delete(a),l.set(a,f)}const _=(u,h=void 0)=>{if(a.activate(),h)h!==we&&(s.f|=se,Ve(s,h));else{(s.f&se)!==0&&(s.f^=se),Ve(s,u);for(const[w,R]of l){if(l.delete(w),w===a)break;R.reject(we)}}o&&(r.update_pending_count(-1),a.decrement(c))};f.promise.then(_,u=>_(null,u||"unknown"))}),nn(()=>{for(const f of l.values())f.reject(we)}),new Promise(f=>{function a(c){function _(){c===i?f(s):a(i)}c.then(_,_)}a(i)})}function Vt(e){const t=ut(e);return cn(t),t}function Wt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)U(t[n])}}function yr(e){for(var t=e.parent;t!==null;){if((t.f&E)===0)return(t.f&G)===0?t:null;t=t.parent}return null}function ct(e){var t,n=g;j(yr(e));try{e.f&=~ue,Wt(e),t=pn(e)}finally{j(n)}return t}function Gt(e){var t=ct(e);if(e.equals(t)||(b?.is_fork||(e.v=t),e.wv=_n()),!_e)if(P!==null)We()&&P.set(e,t);else{var n=(e.f&q)===0?W:k;A(e,n)}}let dt=new Set;const oe=new Map;let zt=!1;function Ne(e,t){var n={f:0,v:e,reactions:null,equals:Mt,rv:0,wv:0};return n}function T(e,t){const n=Ne(e);return cn(n),n}function br(e,t=!1,n=!0){const r=Ne(e);return t||(r.equals=ar),r}function $(e,t,n=!1){v!==null&&(!Y||(v.f&Ct)!==0)&&Ft()&&(v.f&(E|V|st|Ct))!==0&&!Q?.includes(e)&&rr();let r=n?Se(t):t;return Ve(e,r)}function Ve(e,t){if(!e.equals(t)){var n=e.v;_e?oe.set(e,t):oe.set(e,n),e.v=t;var r=B.ensure();r.capture(e,n),(e.f&E)!==0&&((e.f&O)!==0&&ct(e),A(e,(e.f&q)!==0?k:W)),e.wv=_n(),Kt(e,O),g!==null&&(g.f&k)!==0&&(g.f&(ne|re))===0&&(I===null?Ir([e]):I.push(e)),!r.is_fork&&dt.size>0&&!zt&&$r()}return t}function $r(){zt=!1;var e=le;ze(!0);const t=Array.from(dt);try{for(const n of t)(n.f&k)!==0&&A(n,W),Re(n)&&Le(n)}finally{ze(e)}dt.clear()}function Er(e,t=1){var n=d(e),r=t===1?n++:n--;return $(e,n),r}function ke(e){$(e,e.v+1)}function Kt(e,t){var n=e.reactions;if(n!==null)for(var r=n.length,i=0;i<r;i++){var s=n[i],o=s.f,l=(o&O)===0;if(l&&A(s,t),(o&E)!==0){var f=s;P?.delete(f),(o&ue)===0&&(o&q&&(s.f|=ue),Kt(f,W))}else l&&((o&V)!==0&&K!==null&&K.add(s),$e(s))}}function Se(e){if(typeof e!="object"||e===null||ot in e)return e;const t=St(e);if(t!==Hn&&t!==Yn)return e;var n=new Map,r=Fn(e),i=T(0),s=ve,o=l=>{if(ve===s)return l();var f=v,a=ve;N(null),hn(s);var c=l();return N(f),hn(a),c};return r&&n.set("length",T(e.length)),new Proxy(e,{defineProperty(l,f,a){(!("value"in a)||a.configurable===!1||a.enumerable===!1||a.writable===!1)&&tr();var c=n.get(f);return c===void 0?c=o(()=>{var _=T(a.value);return n.set(f,_),_}):$(c,a.value,!0),!0},deleteProperty(l,f){var a=n.get(f);if(a===void 0){if(f in l){const c=o(()=>T(x));n.set(f,c),ke(i)}}else $(a,x),ke(i);return!0},get(l,f,a){if(f===ot)return e;var c=n.get(f),_=f in l;if(c===void 0&&(!_||ge(l,f)?.writable)&&(c=o(()=>{var h=Se(_?l[f]:x),w=T(h);return w}),n.set(f,c)),c!==void 0){var u=d(c);return u===x?void 0:u}return Reflect.get(l,f,a)},getOwnPropertyDescriptor(l,f){var a=Reflect.getOwnPropertyDescriptor(l,f);if(a&&"value"in a){var c=n.get(f);c&&(a.value=d(c))}else if(a===void 0){var _=n.get(f),u=_?.v;if(_!==void 0&&u!==x)return{enumerable:!0,configurable:!0,value:u,writable:!0}}return a},has(l,f){if(f===ot)return!0;var a=n.get(f),c=a!==void 0&&a.v!==x||Reflect.has(l,f);if(a!==void 0||g!==null&&(!c||ge(l,f)?.writable)){a===void 0&&(a=o(()=>{var u=c?Se(l[f]):x,h=T(u);return h}),n.set(f,a));var _=d(a);if(_===x)return!1}return c},set(l,f,a,c){var _=n.get(f),u=f in l;if(r&&f==="length")for(var h=a;h<_.v;h+=1){var w=n.get(h+"");w!==void 0?$(w,x):h in l&&(w=o(()=>T(x)),n.set(h+"",w))}if(_===void 0)(!u||ge(l,f)?.writable)&&(_=o(()=>T(void 0)),$(_,Se(a)),n.set(f,_));else{u=_.v!==x;var R=o(()=>Se(a));$(_,R)}var ee=Reflect.getOwnPropertyDescriptor(l,f);if(ee?.set&&ee.set.call(c,a),!u){if(r&&typeof f=="string"){var Qe=n.get("length"),Pe=Number(f);Number.isInteger(Pe)&&Pe>=Qe.v&&$(Qe,Pe+1)}ke(i)}return!0},ownKeys(l){d(i);var f=Reflect.ownKeys(l).filter(_=>{var u=n.get(_);return u===void 0||u.v!==x});for(var[a,c]of n)c.v!==x&&!(a in l)&&f.push(a);return f},setPrototypeOf(){nr()}})}var Xt,Zt,Qt,en;function ht(){if(Xt===void 0){Xt=window,Zt=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;Qt=ge(t,"firstChild").get,en=ge(t,"nextSibling").get,At(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),At(n)&&(n.__t=void 0)}}function Ae(e=""){return document.createTextNode(e)}function Oe(e){return Qt.call(e)}function X(e){return en.call(e)}function tn(e,t){if(!y)return Oe(e);var n=Oe(m);return n===null&&(n=m.appendChild(Ae())),z(n),n}function xr(e,t=!1){if(!y){var n=Oe(e);return n instanceof Comment&&n.data===""?X(n):n}if(t&&m?.nodeType!==Lt){var r=Ae();return m?.before(r),z(r),r}return m}function Z(e,t=1,n=!1){let r=y?m:e;for(var i;t--;)i=r,r=X(r);if(!y)return r;if(n&&r?.nodeType!==Lt){var s=Ae();return r===null?i?.after(s):r.before(s),z(s),s}return z(r),r}function Tr(e){e.textContent=""}function _t(e){var t=v,n=g;N(null),j(null);try{return e()}finally{N(t),j(n)}}function Nr(e){g===null&&(v===null&&Zn(),Xn()),_e&&Kn()}function kr(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function H(e,t,n){var r=g;r!==null&&(r.f&ie)!==0&&(e|=ie);var i={ctx:D,deps:null,nodes_start:null,nodes_end:null,f:e|O|q,first:null,fn:t,last:null,next:null,parent:r,b:r&&r.b,prev:null,teardown:null,transitions:null,wv:0,ac:null};if(n)try{Le(i),i.f|=Fe}catch(l){throw U(i),l}else t!==null&&$e(i);var s=i;if(n&&s.deps===null&&s.teardown===null&&s.nodes_start===null&&s.first===s.last&&(s.f&ae)===0&&(s=s.first,(e&V)!==0&&(e&qe)!==0&&s!==null&&(s.f|=qe)),s!==null&&(s.parent=r,r!==null&&kr(s,r),v!==null&&(v.f&E)!==0&&(e&re)===0)){var o=v;(o.effects??=[]).push(s)}return i}function We(){return v!==null&&!Y}function nn(e){const t=H(rt,null,!1);return A(t,k),t.teardown=e,t}function Sr(e){Nr();var t=g.f,n=!v&&(t&ne)!==0&&(t&Fe)===0;if(n){var r=D;(r.e??=[]).push(e)}else return rn(e)}function rn(e){return H(nt|Vn,e,!1)}function Ar(e){B.ensure();const t=H(re|ae,e,!0);return()=>{U(t)}}function Or(e){B.ensure();const t=H(re|ae,e,!0);return(n={})=>new Promise(r=>{n.outro?Ge(t,()=>{U(t),r(void 0)}):(U(t),r(void 0))})}function Cr(e){return H(nt,e,!1)}function Rr(e){return H(st|ae,e,!0)}function sn(e,t=0){return H(rt|t,e,!0)}function de(e,t=[],n=[],r=[]){gr(r,t,n,i=>{H(rt,()=>e(...i.map(d)),!0)})}function Lr(e,t=0){var n=H(V|t,e,!0);return n}function he(e){return H(ne|ae,e,!0)}function on(e){var t=e.teardown;if(t!==null){const n=_e,r=v;un(!0),N(null);try{t.call(null)}finally{un(n),N(r)}}}function ln(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){const i=n.ac;i!==null&&_t(()=>{i.abort(we)});var r=n.next;(n.f&re)!==0?n.parent=null:U(n,t),n=r}}function Dr(e){for(var t=e.first;t!==null;){var n=t.next;(t.f&ne)===0&&U(t),t=n}}function U(e,t=!0){var n=!1;(t||(e.f&Rt)!==0)&&e.nodes_start!==null&&e.nodes_end!==null&&(Pr(e.nodes_start,e.nodes_end),n=!0),ln(e,t&&!n),Ke(e,0),A(e,G);var r=e.transitions;if(r!==null)for(const s of r)s.stop();on(e);var i=e.parent;i!==null&&i.first!==null&&fn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes_start=e.nodes_end=e.ac=null}function Pr(e,t){for(;e!==null;){var n=e===t?null:X(e);e.remove(),e=n}}function fn(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function Ge(e,t,n=!0){var r=[];an(e,r,!0),Mr(r,()=>{n&&U(e),t&&t()})}function Mr(e,t){var n=e.length;if(n>0){var r=()=>--n||t();for(var i of e)i.out(r)}else t()}function an(e,t,n){if((e.f&ie)===0){if(e.f^=ie,e.transitions!==null)for(const o of e.transitions)(o.is_global||n)&&t.push(o);for(var r=e.first;r!==null;){var i=r.next,s=(r.f&qe)!==0||(r.f&ne)!==0&&(e.f&V)!==0;an(r,t,s?n:!1),r=i}}}function jr(e,t){for(var n=e.nodes_start,r=e.nodes_end;n!==null;){var i=n===r?null:X(n);t.append(n),n=i}}let le=!1;function ze(e){le=e}let _e=!1;function un(e){_e=e}let v=null,Y=!1;function N(e){v=e}let g=null;function j(e){g=e}let Q=null;function cn(e){v!==null&&(Q===null?Q=[e]:Q.push(e))}let S=null,C=0,I=null;function Ir(e){I=e}let dn=1,Ce=0,ve=Ce;function hn(e){ve=e}function _n(){return++dn}function Re(e){var t=e.f;if((t&O)!==0)return!0;if(t&E&&(e.f&=~ue),(t&W)!==0){var n=e.deps;if(n!==null)for(var r=n.length,i=0;i<r;i++){var s=n[i];if(Re(s)&&Gt(s),s.wv>e.wv)return!0}(t&q)!==0&&P===null&&A(e,k)}return!1}function vn(e,t,n=!0){var r=e.reactions;if(r!==null&&!Q?.includes(e))for(var i=0;i<r.length;i++){var s=r[i];(s.f&E)!==0?vn(s,t,!1):t===s&&(n?A(s,O):(s.f&k)!==0&&A(s,W),$e(s))}}function pn(e){var t=S,n=C,r=I,i=v,s=Q,o=D,l=Y,f=ve,a=e.f;S=null,C=0,I=null,v=(a&(ne|re))===0?e:null,Q=null,ye(e.ctx),Y=!1,ve=++Ce,e.ac!==null&&(_t(()=>{e.ac.abort(we)}),e.ac=null);try{e.f|=it;var c=e.fn,_=c(),u=e.deps;if(S!==null){var h;if(Ke(e,C),u!==null&&C>0)for(u.length=C+S.length,h=0;h<S.length;h++)u[C+h]=S[h];else e.deps=u=S;if(le&&We()&&(e.f&q)!==0)for(h=C;h<u.length;h++)(u[h].reactions??=[]).push(e)}else u!==null&&C<u.length&&(Ke(e,C),u.length=C);if(Ft()&&I!==null&&!Y&&u!==null&&(e.f&(E|W|O))===0)for(h=0;h<I.length;h++)vn(I[h],e);return i!==null&&i!==e&&(Ce++,I!==null&&(r===null?r=I:r.push(...I))),(e.f&se)!==0&&(e.f^=se),_}catch(w){return Bt(w)}finally{e.f^=it,S=t,C=n,I=r,v=i,Q=s,ye(o),Y=l,ve=f}}function Fr(e,t){let n=t.reactions;if(n!==null){var r=qn.call(n,e);if(r!==-1){var i=n.length-1;i===0?n=t.reactions=null:(n[r]=n[i],n.pop())}}n===null&&(t.f&E)!==0&&(S===null||!S.includes(t))&&(A(t,W),(t.f&q)!==0&&(t.f^=q,t.f&=~ue),Wt(t),Ke(t,0))}function Ke(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)Fr(e,n[r])}function Le(e){var t=e.f;if((t&G)===0){A(e,k);var n=g,r=le;g=e,le=!0;try{(t&V)!==0?Dr(e):ln(e),on(e);var i=pn(e);e.teardown=typeof i=="function"?i:null,e.wv=dn;var s;tt&&ur&&(e.f&O)!==0&&e.deps}finally{le=r,g=n}}}function d(e){var t=e.f,n=(t&E)!==0;if(v!==null&&!Y){var r=g!==null&&(g.f&G)!==0;if(!r&&!Q?.includes(e)){var i=v.deps;if((v.f&it)!==0)e.rv<Ce&&(e.rv=Ce,S===null&&i!==null&&i[C]===e?C++:S===null?S=[e]:S.includes(e)||S.push(e));else{(v.deps??=[]).push(e);var s=e.reactions;s===null?e.reactions=[v]:s.includes(v)||s.push(v)}}}if(_e){if(oe.has(e))return oe.get(e);if(n){var o=e,l=o.v;return((o.f&k)===0&&o.reactions!==null||wn(o))&&(l=ct(o)),oe.set(o,l),l}}else n&&!P?.has(e)&&(o=e,Re(o)&&Gt(o),le&&We()&&(o.f&q)===0&&gn(o));if(P?.has(e))return P.get(e);if((e.f&se)!==0)throw e.v;return e.v}function gn(e){if(e.deps!==null){e.f^=q;for(const t of e.deps)(t.reactions??=[]).push(e),(t.f&E)!==0&&(t.f&q)===0&&gn(t)}}function wn(e){if(e.v===x)return!0;if(e.deps===null)return!1;for(const t of e.deps)if(oe.has(t)||(t.f&E)!==0&&wn(t))return!0;return!1}function qr(e){var t=Y;try{return Y=!0,e()}finally{Y=t}}const Br=-7169;function A(e,t){e.f=e.f&Br|t}const mn=new Set,vt=new Set;function Ur(e,t,n,r={}){function i(s){if(r.capture||De.call(t,s),!s.cancelBubble)return _t(()=>n?.call(this,s))}return e.startsWith("pointer")||e.startsWith("touch")||e==="wheel"?Ue(()=>{t.addEventListener(e,i,r)}):t.addEventListener(e,i,r),i}function Xe(e,t,n,r,i){var s={capture:r,passive:i},o=Ur(e,t,n,s);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&nn(()=>{t.removeEventListener(e,o,s)})}function Hr(e){for(var t=0;t<e.length;t++)mn.add(e[t]);for(var n of vt)n(e)}let yn=null;function De(e){var t=this,n=t.ownerDocument,r=e.type,i=e.composedPath?.()||[],s=i[0]||e.target;yn=e;var o=0,l=yn===e&&e.__root;if(l){var f=i.indexOf(l);if(f!==-1&&(t===document||t===window)){e.__root=t;return}var a=i.indexOf(t);if(a===-1)return;f<=a&&(o=f)}if(s=i[o]||e.target,s!==t){je(e,"currentTarget",{configurable:!0,get(){return s||n}});var c=v,_=g;N(null),j(null);try{for(var u,h=[];s!==null;){var w=s.assignedSlot||s.parentNode||s.host||null;try{var R=s["__"+r];R!=null&&(!s.disabled||e.target===s)&&R.call(s,e)}catch(ee){u?h.push(ee):u=ee}if(e.cancelBubble||w===t||w===null)break;s=w}if(u){for(let ee of h)queueMicrotask(()=>{throw ee});throw u}}finally{e.__root=t,delete e.currentTarget,N(c),j(_)}}}function Yr(e){var t=document.createElement("template");return t.innerHTML=e.replaceAll("<!>","<!---->"),t.content}function pt(e,t){var n=g;n.nodes_start===null&&(n.nodes_start=e,n.nodes_end=t)}function Jr(e,t){var n=(t&jn)!==0,r,i=!e.startsWith("<!>");return()=>{if(y)return pt(m,null),m;r===void 0&&(r=Yr(i?e:"<!>"+e));var s=n||Zt?document.importNode(r,!0):r.cloneNode(!0);{var o=Oe(s),l=s.lastChild;pt(o,l)}return s}}function bn(e,t){if(y){var n=g;((n.f&Fe)===0||n.nodes_end===null)&&(n.nodes_end=m),Dt();return}e!==null&&e.before(t)}const Vr=["touchstart","touchmove"];function Wr(e){return Vr.includes(e)}function $n(e,t){return En(e,t)}function Gr(e,t){ht(),t.intro=t.intro??!1;const n=t.target,r=y,i=m;try{for(var s=Oe(n);s&&(s.nodeType!==Be||s.data!==Tt);)s=X(s);if(!s)throw xe;me(!0),z(s);const o=En(e,{...t,anchor:s});return me(!1),o}catch(o){if(o instanceof Error&&o.message.split(`
2
+ `).some(l=>l.startsWith("https://svelte.dev/e/")))throw o;return o!==xe&&console.warn("Failed to hydrate: ",o),t.recover===!1&&er(),ht(),Tr(n),me(!1),$n(e,t)}finally{me(r),z(i)}}const Ee=new Map;function En(e,{target:t,anchor:n,props:r={},events:i,context:s,intro:o=!0}){ht();var l=new Set,f=_=>{for(var u=0;u<_.length;u++){var h=_[u];if(!l.has(h)){l.add(h);var w=Wr(h);t.addEventListener(h,De,{passive:w});var R=Ee.get(h);R===void 0?(document.addEventListener(h,De,{passive:w}),Ee.set(h,1)):Ee.set(h,R+1)}}};f(Bn(mn)),vt.add(f);var a=void 0,c=Or(()=>{var _=n??t.appendChild(Ae());return vr(_,{pending:()=>{}},u=>{if(s){jt({});var h=D;h.c=s}if(i&&(r.$$events=i),y&&pt(u,null),a=e(u,r)||{},y&&(g.nodes_end=m,m===null||m.nodeType!==Be||m.data!==kt))throw lt(),xe;s&&It()}),()=>{for(var u of l){t.removeEventListener(u,De);var h=Ee.get(u);--h===0?(document.removeEventListener(u,De),Ee.delete(u)):Ee.set(u,h)}vt.delete(f),_!==n&&_.parentNode?.removeChild(_)}});return gt.set(a,c),a}let gt=new WeakMap;function zr(e,t){const n=gt.get(e);return n?(gt.delete(e),n(t)):Promise.resolve()}function Kr(e,t){Cr(()=>{var n=e.getRootNode(),r=n.host?n:n.head??n.ownerDocument.head;if(!r.querySelector("#"+t.hash)){const i=document.createElement("style");i.id=t.hash,i.textContent=t.code,r.appendChild(i)}})}const Xr=Symbol("is custom element"),Zr=Symbol("is html");function Qr(e,t,n,r){var i=ei(e);y&&(i[t]=e.getAttribute(t),t==="src"||t==="srcset"||t==="href"&&e.nodeName==="LINK")||i[t]!==(i[t]=n)&&(t==="loading"&&(e[Gn]=n),n==null?e.removeAttribute(t):typeof n!="string"&&xn(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function F(e,t,n){var r=v,i=g;let s=y;y&&me(!1),N(null),j(null);try{t!=="style"&&(wt.has(e.getAttribute("is")||e.nodeName)||!customElements||customElements.get(e.getAttribute("is")||e.tagName.toLowerCase())?xn(e).includes(t):n&&typeof n=="object")?e[t]=n:Qr(e,t,n==null?n:String(n))}finally{N(r),j(i),s&&me(!0)}}function ei(e){return e.__attributes??={[Xr]:e.nodeName.includes("-"),[Zr]:e.namespaceURI===In}}var wt=new Map;function xn(e){var t=e.getAttribute("is")||e.nodeName,n=wt.get(t);if(n)return n;wt.set(t,n=[]);for(var r,i=e,s=Element.prototype;s!==i;){r=Un(i);for(var o in r)r[o].set&&n.push(o);i=St(i)}return n}function Tn(e,t,n,r){var i=r,s=!0,o=()=>(s&&(s=!1,i=r),i),l;l=e[t],l===void 0&&r!==void 0&&(l=o());var f;f=()=>{var u=e[t];return u===void 0?o():(s=!0,u)};var a=!1,c=ut(()=>(a=!1,f())),_=g;return(function(u,h){if(arguments.length>0){const w=h?d(c):u;return $(c,w),a=!0,i!==void 0&&(i=w),u}return _e&&a||(_.f&G)!==0?c.v:d(c)})}function ti(e){return new ni(e)}class ni{#t;#e;constructor(t){var n=new Map,r=(s,o)=>{var l=br(o,!1,!1);return n.set(s,l),l};const i=new Proxy({...t.props||{},$$events:{}},{get(s,o){return d(n.get(o)??r(o,Reflect.get(s,o)))},has(s,o){return o===Wn?!0:(d(n.get(o)??r(o,Reflect.get(s,o))),Reflect.has(s,o))},set(s,o,l){return $(n.get(o)??r(o,l),l),Reflect.set(s,o,l)}});this.#e=(t.hydrate?Gr:$n)(t.component,{target:t.target,anchor:t.anchor,props:i,context:t.context,intro:t.intro??!1,recover:t.recover}),(!t?.props?.$$host||t.sync===!1)&&at(),this.#t=i.$$events;for(const s of Object.keys(this.#e))s==="$set"||s==="$destroy"||s==="$on"||je(this,s,{get(){return this.#e[s]},set(o){this.#e[s]=o},enumerable:!0});this.#e.$set=s=>{Object.assign(i,s)},this.#e.$destroy=()=>{zr(this.#e)}}$set(t){this.#e.$set(t)}$on(t,n){this.#t[t]=this.#t[t]||[];const r=(...i)=>n.call(this,...i);return this.#t[t].push(r),()=>{this.#t[t]=this.#t[t].filter(i=>i!==r)}}$destroy(){this.#e.$destroy()}}let Nn;typeof HTMLElement=="function"&&(Nn=class extends HTMLElement{$$ctor;$$s;$$c;$$cn=!1;$$d={};$$r=!1;$$p_d={};$$l={};$$l_u=new Map;$$me;constructor(e,t,n){super(),this.$$ctor=e,this.$$s=t,n&&this.attachShadow({mode:"open"})}addEventListener(e,t,n){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const r=this.$$c.$on(e,t);this.$$l_u.set(t,r)}super.addEventListener(e,t,n)}removeEventListener(e,t,n){if(super.removeEventListener(e,t,n),this.$$c){const r=this.$$l_u.get(t);r&&(r(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(r){return i=>{const s=document.createElement("slot");r!=="default"&&(s.name=r),bn(i,s)}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},n=ri(this);for(const r of this.$$s)r in n&&(r==="default"&&!this.$$d.children?(this.$$d.children=e(r),t.default=!0):t[r]=e(r));for(const r of this.attributes){const i=this.$$g_p(r.name);i in this.$$d||(this.$$d[i]=Ze(i,r.value,this.$$p_d,"toProp"))}for(const r in this.$$p_d)!(r in this.$$d)&&this[r]!==void 0&&(this.$$d[r]=this[r],delete this[r]);this.$$c=ti({component:this.$$ctor,target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$host:this}}),this.$$me=Ar(()=>{sn(()=>{this.$$r=!0;for(const r of Me(this.$$c)){if(!this.$$p_d[r]?.reflect)continue;this.$$d[r]=this.$$c[r];const i=Ze(r,this.$$d[r],this.$$p_d,"toAttribute");i==null?this.removeAttribute(this.$$p_d[r].attribute||r):this.setAttribute(this.$$p_d[r].attribute||r,i)}this.$$r=!1})});for(const r in this.$$l)for(const i of this.$$l[r]){const s=this.$$c.$on(r,i);this.$$l_u.set(i,s)}this.$$l={}}}attributeChangedCallback(e,t,n){this.$$r||(e=this.$$g_p(e),this.$$d[e]=Ze(e,n,this.$$p_d,"toProp"),this.$$c?.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$me(),this.$$c=void 0)})}$$g_p(e){return Me(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function Ze(e,t,n,r){const i=n[e]?.type;if(t=i==="Boolean"&&typeof t!="boolean"?t!=null:t,!r||!n[e])return t;if(r==="toAttribute")switch(i){case"Object":case"Array":return t==null?null:JSON.stringify(t);case"Boolean":return t?"":null;case"Number":return t??null;default:return t}else switch(i){case"Object":case"Array":return t&&JSON.parse(t);case"Boolean":return t;case"Number":return t!=null?+t:t;default:return t}}function ri(e){const t={};return e.childNodes.forEach(n=>{t[n.slot||"default"]=!0}),t}function ii(e,t,n,r,i,s){let o=class extends Nn{constructor(){super(e,n,i),this.$$p_d=t}static get observedAttributes(){return Me(t).map(l=>(t[l].attribute||l).toLowerCase())}};return Me(t).forEach(l=>{je(o.prototype,l,{get(){return this.$$c&&l in this.$$c?this.$$c[l]:this.$$d[l]},set(f){f=Ze(l,f,t),this.$$d[l]=f;var a=this.$$c;if(a){var c=ge(a,l)?.get;c?a[l]=f:a.$set({[l]:f})}}})}),r.forEach(l=>{je(o.prototype,l,{get(){return this.$$c?.[l]}})}),e.element=o,o}const kn={version:"0.66.0"};var pe={},Sn;function si(){if(Sn)return pe;Sn=1,Object.defineProperty(pe,"__esModule",{value:!0}),pe.LanguageTranslator=void 0,pe.getChildStyleToPass=e,pe.addComponent=t;function e(r,i){var s,o,l="";try{if(r&&i?.length&&(!((s=Object.keys(r))===null||s===void 0)&&s.length)&&(!((o=i?.filter(function(u){return Object.keys(r).includes(u.name)}))===null||o===void 0)&&o.length))for(var f=function(u){var h=i?.filter(function(w){return w.name===u&&w.defaultValue!==r[u]});h&&(l+="".concat(u,":").concat(r[u],";"))},a=0,c=Object.keys(r);a<c.length;a++){var _=c[a];f(_)}}catch(u){console.error("error getting child style to pass",u)}finally{return l}}function t(r){var i,s=((i=r?.repoName.split("/"))===null||i===void 0?void 0:i[1])||r?.repoName;if(!s)throw new Error("wrong componentPath "+r?.repoName);if(!r?.version)throw new Error("wrong version "+r?.version);var o=r?.iifePath||"main.iife.js";if(!document.getElementById(s+"-script"))try{var l=document.createElement("script");if(l.id=s+"-script",l.src="https://cdn.jsdelivr.net/npm/".concat(r.repoName,"@").concat(r.version,"/").concat(o),r?.local)l.src="".concat(r.local);else if(location.href.includes("localhost:6006")){var f=s.split("-")[0];l.src="http://localhost:6006/webcomponents/".concat(s.replace(f+"-",""),"/").concat(o)}document.head.appendChild(l)}catch(a){console.warn(a)}}var n=(function(){function r(i){if(this.lang="",!i?.dictionary)throw new Error("no dictionary provided");this.dictionary=i.dictionary,this.setLang(i?.lang)}return r.prototype.setLang=function(i){i||(i=r.getDefaultLang()),this.lang=i},r.prototype.translateWord=function(i,s){return r.getDictionaryWord(i,this.dictionary,s||this.lang)},r.prototype.translateDate=function(i,s,o){return r.formatDate(i,s,o||this.lang)},r.getDefaultLang=function(){var i,s,o,l="en";return navigator?.languages&&(!((o=(s=(i=navigator.languages[0])===null||i===void 0?void 0:i.split("-")[0])===null||s===void 0?void 0:s.toLowerCase())===null||o===void 0)&&o.length)&&(l=navigator.languages[0].split("-")[0].toLowerCase()),l},r.getDictionaryWord=function(i,s,o){var l;if(!i)throw new Error("no wordKey provided");if(!s)throw new Error("no dictionary provided");if(o&&(!((l=s[o])===null||l===void 0)&&l[i]))return s[o][i];var f="",a=r.getDefaultLang();if(!o||a!==o){var c=s?.[a];c?.[i]&&(f=c[i])}return f},r.formatDate=function(i,s,o){if(!i)throw new Error("no date provided");if(typeof i.getMonth!="function")throw new Error("wrong date format");var l=new Intl.DateTimeFormat(o||r.getDefaultLang(),s);return l.format(i)},r})();return pe.LanguageTranslator=n,pe}var An=si(),oi=Jr('<div part="controller" id="controller" class="svelte-1swbd4i"><button>clear</button> <button>select</button> <button>draw</button> <button>undo</button> <button>redo</button> <button>save</button> <button>brush</button> <br/>load:<hb-input-file></hb-input-file> insert:<hb-input-file></hb-input-file></div> <div part="paper-container" id="paper-container" style="position:relative" class="svelte-1swbd4i"><hb-stylus-paper></hb-stylus-paper></div>',3);const li={hash:"svelte-1swbd4i",code:'@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap");:host {font-family:"Roboto", sans-serif;position:absolute;width:100%;height:100%;display:block;display:grid;grid-template-areas:"header" "paper";grid-template-columns:1fr;grid-template-rows:auto 1fr;}#controller.svelte-1swbd4i {grid-area:header;}#paper-container.svelte-1swbd4i {grid-area:paper;background:green;}'};function On(e,t){jt(t,!0),Kr(e,li);let n=Tn(t,"id",7,""),r=Tn(t,"load_draw"),i=T("draw"),s=T(0),o=T(void 0),l=T(!1),f=T(void 0),a=T(void 0),c=T(void 0),_=T(void 0),u=Vt(()=>(d(o)===0||d(o))&&d(o)<d(s)),h=Vt(()=>(d(s)||d(s)===0)&&d(l)&&(!d(o)||d(o)!==-1)&&(!d(_)||d(_)<d(s)&&(!d(o)||d(o)<d(_))));Sr(()=>{if(typeof r()=="string"&&r()?.length)try{r(JSON.parse(r()))}catch(p){console.error("error parsing json",p)}}),An.addComponent({repoName:"@htmlbricks/hb-stylus-paper",version:kn.version}),An.addComponent({repoName:"@htmlbricks/hb-input-file",version:kn.version});function w(p,fe){var te="data:text/json;charset=utf-8,"+encodeURIComponent(JSON.stringify(p)),L=document.createElement("a");L.setAttribute("href",te),L.setAttribute("download",fe),document.body.appendChild(L),L.click(),L.remove()}function R(p){$(i,p,!0)}function ee(){console.log("ch",d(s),d(o)),d(s)>=0&&(!d(o)||d(o)>-1)&&($(o,d(o)||d(o)===0?d(o)-1:d(s)-1,!0),console.log("undo",d(s),d(o)))}function Qe(){console.log(d(s),d(o)),(d(o)||d(o)===0)&&d(o)<=d(s)&&(Er(o),console.log("redo",d(s),d(o)))}function Pe(p){d(l)||$(l,!0),console.log("h",p),$(s,p.index-1),p.start_index&&$(_,p.start_index,!0),$(o,void 0)}function fi(){$(f,{name:"test",type:"json"},!0)}function ai(p){const fe=p.value?.name;if(fe){const te=new FileReader;te.readAsDataURL(p.value),te.onload=function(L){try{if(console.log("insert file",L.target,L.target?.result),L.target?.result){const _i=L.target.result.toString().split(";")[0].split("/")[1];$(a,{base64:L.target.result.toString(),type:_i,name:fe},!0)}}catch{console.error("error loading file")}},te.onerror=function(L){console.error("error reading file")}}}function ui(p){console.log("save",p),$(f,void 0),w(p,p?.name+".json")}function ci(p){if(console.log("file",p),p.value?.name){const fe=new FileReader;fe.readAsText(p.value,"UTF-8"),fe.onload=function(te){if(te?.target?.result?.toString())try{r(JSON.parse(te.target.result.toString()))}catch{console.error("error loading file")}},fe.onerror=function(te){console.error("error reading file")}}}var di={get id(){return n()},set id(p=""){n(p),at()},get load_draw(){return r()},set load_draw(p){r(p),at()}},Cn=oi(),mt=xr(Cn),Rn=tn(mt);Rn.__click=()=>R("eraser");var Ln=Z(Rn,2);Ln.__click=()=>R("select");var Dn=Z(Ln,2);Dn.__click=()=>R("draw");var yt=Z(Dn,2);yt.__click=()=>ee();var bt=Z(yt,2);bt.__click=()=>Qe();var $t=Z(bt,2);$t.__click=()=>fi();var Pn=Z($t,2),et=Z(Pn,4);F(et,"id","loadfile"),F(et,"schemaentry",JSON.stringify({label:"ciao",id:"xxxxxxx"}));var Et=Z(et,2);F(Et,"id","insertfile"),F(Et,"schemaentry",JSON.stringify({label:"ciao"})),Pt(mt);var Mn=Z(mt,2),J=tn(Mn);return F(J,"id","stylus-paper"),de(()=>F(J,"goto",d(o))),F(J,"background_color","green"),de(()=>F(J,"mode",d(i))),de(()=>F(J,"save_as",d(f)?JSON.stringify(d(f)):"")),de(()=>F(J,"load_draw",r()?JSON.stringify(r()):null)),de(()=>F(J,"insert_image",d(a)?JSON.stringify(d(a)):null)),de(()=>F(J,"insert_text",d(c)?JSON.stringify(d(c)):null)),Pt(Mn),de(()=>{yt.disabled=!d(h),bt.disabled=!d(u),$t.disabled=!d(h),Pn.disabled=d(i)!=="draw"}),Xe("setVal",et,p=>ci(p.detail)),Xe("setVal",Et,p=>ai(p.detail)),Xe("historyIndex",J,p=>Pe(p.detail)),Xe("save",J,p=>ui(p.detail)),bn(e,Cn),It(di)}Hr(["click"]),customElements.define("hb-stylus-notebook",ii(On,{id:{},load_draw:{}},[],[],!0)),xt.Component=On,Object.defineProperty(xt,Symbol.toStringTag,{value:"Module"})})(this["stylus-notebook"]=this["stylus-notebook"]||{});
3
3
  //# sourceMappingURL=main.iife.js.map