diff --git a/docs/_app/assets/pages/index.svelte-90c8a385.css b/docs/_app/assets/pages/index.svelte-90c8a385.css new file mode 100644 index 0000000..5394573 --- /dev/null +++ b/docs/_app/assets/pages/index.svelte-90c8a385.css @@ -0,0 +1 @@ +header.svelte-1me5k9w{display:flex;align-items:baseline;width:var(--main-width);margin-left:auto;margin-right:auto}h1.svelte-1me5k9w,h2.svelte-1me5k9w{font-family:Faktos;padding:0;margin:0}h2.svelte-1me5k9w{text-align:right;flex:1;padding-left:2em;font-size:var(--font-scale-12)}pre.svelte-2g9858{font-family:monospace;font-size:var(--font-scale-9);overflow:scroll;height:90%}aside.svelte-2g9858{padding:1em;border:3px solid var(--indigo-dye);border-radius:1em;font-size:var(--font-scale-11)}div.svelte-1oeefsn:after{content:'\00A4';margin-left:.5em}div.svelte-ylboiy:after{content:url(/aotds-docks/_app/mass.svg);width:.75em;display:inline-block;margin-left:.5em}h1.svelte-bo35k{width:100%;display:flex;font-size:var(--font-scale-8)}h2.svelte-bo35k{font-size:var(--font-scale-7);flex:1}.fill.svelte-bo35k{margin-left:.5em;display:inline-block;flex:1;border-bottom:1px solid #000}.details.svelte-bo35k{display:flex;align-items:baseline}.reqs.svelte-bo35k{display:flex}.thrust.svelte-w7le23{background-image:url(icons/standard-drive.svg);width:2em;background-size:2em;background-repeat:no-repeat;height:2em;line-height:2em;text-align:center}.main_systems.svelte-w7le23{display:flex;align-items:center;gap:1em;justify-content:space-evenly;margin-top:1em}img.ftl.svelte-w7le23{height:2em}img.internal.svelte-w7le23{height:2em}.cell.svelte-qekx9g{display:inline-block;margin-right:.5em;width:1em;height:1em;border:1px solid #000}img.svelte-qekx9g{width:1em}.cell.svelte-15e5q3d{display:inline-block;margin-right:.5em;width:1em;height:1em;border:1px solid #000;border-radius:.5em}.layers.svelte-15e5q3d{display:flex;flex-direction:column-reverse}path.svelte-7q6uh5{fill:#d3d3d3;stroke:#fff;stroke-width:2px}path.svelte-7q6uh5:hover{fill:pink}path.active.svelte-7q6uh5:hover{fill:pink}path.active.svelte-7q6uh5{fill:#313131}circle.svelte-qqgo8u{fill:#fff}div.svelte-1u8rlr5 path:hover{fill:#fff}div.svelte-1u8rlr5 path.active:hover{fill:#000}text.svelte-1u8rlr5{text-anchor:middle;dominant-baseline:central;font-size:var(--font-scale-10)}div.svelte-18nuiwu{margin-bottom:2em}.beams.svelte-18nuiwu{display:flex;justify-content:space-evenly}div.svelte-d2fjdl{display:flex;gap:.5em}img.firecon.svelte-d2fjdl{width:1em}img.svelte-kh7po5{width:1em}div.svelte-kh7po5{display:flex;gap:.5em}div.svelte-ytgy37{text-align:center;flex:1;display:flex;flex-direction:column;align-items:center}div.svelte-ytgy37>*{margin-bottom:1em}.ship-sheet.svelte-5wh1p{width:4.25in;height:5.5in;border:1px solid #000;padding:1em}.section-2.svelte-5wh1p{display:flex;align-items:start}div.svelte-1urp5hr>*{margin-left:1em}div.svelte-1urp5hr>label.svelte-1urp5hr{margin-left:0}label.svelte-1urp5hr.svelte-1urp5hr{font-size:var(--font-scale-8);font-weight:lighter;font-family:Dosis;color:var(--indigo-dye)}div.svelte-fc2507{display:flex;align-items:end;gap:2em}input.svelte-1lxxcoi{width:5em}.mass_symbol.svelte-1lxxcoi:after{content:url(/aotds-docks/_app/mass.svg);width:.75em;display:inline-block;margin-left:.5em}.warning.svelte-1lxxcoi{color:red}.note.svelte-1lxxcoi{font-size:smaller}.mass.svelte-1lxxcoi,div.cost.svelte-1lxxcoi{padding:0 2em;justify-self:right}.mass.svelte-1lxxcoi{grid-column:2}div.cost.svelte-1lxxcoi{grid-column:3}span.cost.svelte-1lxxcoi:after{content:'\00A4';margin-left:.5em}aside.svelte-zox94u{background-color:#fedab8;position:absolute;height:20em;max-width:50%;z-index:200;padding:1em;border:3px solid var(--indigo-dye);border-radius:1em;left:0;border-left:0;border-top-left-radius:0;border-bottom-left-radius:0;top:6em;font-size:var(--font-scale-11)}h3.svelte-zox94u{text-align:center;margin:0}div.svelte-zox94u{text-align:right}div.svelte-cpog4c{margin-bottom:1em}.cost.svelte-cpog4c,.mass.svelte-cpog4c{padding:0 2em;text-align:right}.cost.svelte-cpog4c{grid-column:3}.mass.svelte-cpog4c{grid-column:2}.cost.svelte-cpog4c:after{content:"\00A4";margin-left:.5em}.mass.svelte-cpog4c:after{content:url(/aotds-docks/_app/mass.svg);width:.75em;display:inline-block;margin-left:.5em}.updated{animation-name:svelte-cpog4c-update;animation-duration:1.5s;animation-fill-mode:forwards}@keyframes svelte-cpog4c-update{0%{color:inherit;font-weight:inherit}20%{color:red;font-weight:700}80%{color:red;font-weight:700}100%{color:inherit;font-weight:inherit}}div.svelte-h4qygo{display:flex;grid-column:1/span 3!important;align-items:baseline;gap:1em}h2.svelte-h4qygo{font-weight:700}hr.svelte-h4qygo{flex:1;background:#333}input.svelte-11x6jvv{width:3em}div.svelte-11x6jvv{display:flex;gap:2em}input.svelte-qworsx{width:5em}.layers.svelte-1bx91qz{display:flex}input.svelte-1bx91qz{width:5em}input.svelte-1060pqd{width:5em}div.svelte-6w28yb{display:flex}label.svelte-6w28yb{margin-left:1em}input.svelte-x10nn1{width:5em}label.svelte-1ozsoxu{display:inline;margin-right:1em}div.svelte-3grq2v{display:flex;align-items:end}label.svelte-3grq2v{margin-left:2em}input[type=number].svelte-3grq2v{width:5em}.weapon_row.svelte-4pz13w{display:flex;align-items:center}.weapon_row.svelte-4pz13w>*{margin-right:2em}main.svelte-1on8rko.svelte-1on8rko{display:grid;grid-template-columns:1fr 14em 8em;width:60em;margin-left:auto;margin-right:auto}nav.svelte-1on8rko.svelte-1on8rko{grid-column:1/span 3!important;display:flex;width:60em;margin-left:auto;margin-right:auto;margin-bottom:1em}nav.svelte-1on8rko .spacer.svelte-1on8rko{flex:1}main>*{grid-column:1}footer.svelte-1on8rko.svelte-1on8rko{width:var(--main-width);margin:0 auto;text-align:right}.about.svelte-1on8rko.svelte-1on8rko{margin-right:2em} \ No newline at end of file diff --git a/docs/_app/pages/index.svelte-4e24bb6e.js b/docs/_app/pages/index.svelte-4e24bb6e.js new file mode 100644 index 0000000..68bd465 --- /dev/null +++ b/docs/_app/pages/index.svelte-4e24bb6e.js @@ -0,0 +1 @@ +var t=Object.defineProperty,e=Object.defineProperties,s=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,c=(e,s,n)=>s in e?t(e,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[s]=n,l=(t,e)=>{for(var s in e||(e={}))a.call(e,s)&&c(t,s,e[s]);if(n)for(var s of n(e))r.call(e,s)&&c(t,s,e[s]);return t},o=(t,n)=>e(t,s(n));import{S as i,i as u,s as $,e as h,t as f,k as p,c as d,a as m,g,d as v,n as y,b,f as _,F as w,G as x,H as E,I,J as k,K as O,L as D,M,N as A,O as P,P as T,Q as C,R as S,T as N,U as j,V,W as q,X as L,Y as F,Z as B,_ as U,$ as z,a0 as H,a1 as G,a2 as R,a3 as W,a4 as Y,a5 as J,a6 as Z,a7 as X,a8 as K,a9 as Q,h as tt,aa as et,ab as st,ac as nt,ad as at,j as rt,m as ct,o as lt,v as ot,r as it,w as ut,ae as $t,af as ht,ag as ft,ah as pt,ai as dt,l as mt,D as gt,B as vt,aj as yt,u as bt,E as _t,p as wt,q as xt,ak as Et,A as It,al as kt,am as Ot,an as Dt,ao as Mt,ap as At,aq as Pt,ar as Tt,as as Ct,at as St,au as Nt,x as jt,av as Vt}from"../chunks/vendor-d7482fce.js";import{b as qt}from"../chunks/paths-45dac81d.js";function Lt(t){let e,s,n,a,r,c,l,o,i;return{c(){e=h("header"),s=h("h1"),n=f("The Docks"),a=p(),r=h("h2"),c=f("a "),l=h("a"),o=f("Full Thrust"),i=f(" ship builder"),this.h()},l(t){e=d(t,"HEADER",{class:!0});var u=m(e);s=d(u,"H1",{class:!0});var $=m(s);n=g($,"The Docks"),$.forEach(v),a=y(u),r=d(u,"H2",{class:!0});var h=m(r);c=g(h,"a "),l=d(h,"A",{href:!0});var f=m(l);o=g(f,"Full Thrust"),f.forEach(v),i=g(h," ship builder"),h.forEach(v),u.forEach(v),this.h()},h(){b(s,"class","svelte-1me5k9w"),b(l,"href","https://shop.groundzerogames.co.uk/rules.html"),b(r,"class","svelte-1me5k9w"),b(e,"class","svelte-1me5k9w")},m(t,u){_(t,e,u),w(e,s),w(s,n),w(e,a),w(e,r),w(r,c),w(r,l),w(l,o),w(r,i)},p:x,i:x,o:x,d(t){t&&v(e)}}}class Ft extends i{constructor(t){super(),u(this,t,null,Lt,$,{})}}function Bt(t){let e,s,n,a,r;return{c(){e=h("a"),s=E("svg"),n=E("path"),a=E("path"),r=E("path"),this.h()},l(t){e=d(t,"A",{href:!0,class:!0,"aria-label":!0});var c=m(e);s=d(c,"svg",{width:!0,height:!0,viewBox:!0,style:!0,"aria-hidden":!0},1);var l=m(s);n=d(l,"path",{d:!0},1),m(n).forEach(v),a=d(l,"path",{d:!0,fill:!0,style:!0,class:!0},1),m(a).forEach(v),r=d(l,"path",{d:!0,fill:!0,class:!0},1),m(r).forEach(v),l.forEach(v),c.forEach(v),this.h()},h(){b(n,"d","M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"),b(a,"d","M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"),b(a,"fill","currentColor"),I(a,"transform-origin","130px 106px"),b(a,"class","octo-arm"),b(r,"d","M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"),b(r,"fill","currentColor"),b(r,"class","octo-body"),b(s,"width","80"),b(s,"height","80"),b(s,"viewBox","0 0 250 250"),I(s,"fill","#151513"),I(s,"color","#fff"),I(s,"position","absolute"),I(s,"top","0"),I(s,"border","0"),I(s,"right","0"),b(s,"aria-hidden","true"),b(e,"href",Ut),b(e,"class","github-corner"),b(e,"aria-label","View source on GitHub")},m(t,c){_(t,e,c),w(e,s),w(s,n),w(s,a),w(s,r)},p:x,i:x,o:x,d(t){t&&v(e)}}}const Ut="https://github.com/aotds/aotds-docks";class zt extends i{constructor(t){super(),u(this,t,null,Bt,$,{})}}const Ht=(t={})=>[P(["cost","mass"],t),...Object.values(t||{}).filter((t=>"object"==typeof t)).map((t=>Ht(t)))];function Gt(t){console.log(t);let e=t,{general:s}=e,c=((t,e)=>{var s={};for(var c in t)a.call(t,c)&&e.indexOf(c)<0&&(s[c]=t[c]);if(null!=t&&n)for(var c of n(t))e.indexOf(c)<0&&r.call(t,c)&&(s[c]=t[c]);return s})(e,["general"]);const i=k(Ht,O,D(M("cost")))(o(l({},c),{cost:s.mass,mass:0}));return{mass:A("mass",i),cost:A("cost",i)}}const Rt=t=>Math.ceil(Math.round(10*t)/10);function Wt(t){var e=t;return function(){return e}}function Yt(t){return Array.isArray(t)?t:T((""+t).split("."),(function(t){return!t}))}var Jt=C.placeholder;function Zt(t,e){return void 0===e&&(e=t.length),C(t,e)}var Xt=Zt((function(t,e,s){for(var n=Yt(t),a=s,r=0;r0==t.length?()=>t=>t:t.reduce(((t,e)=>(s=null,n)=>a=>e(s,n)(t(s,n)(a))));function we(t={},e={},s=[]){const n=Object.entries(e).map((([t,e])=>(s,n)=>be.updateIn(t,e(n)))),a=s.map((t=>(e,s)=>t(s))),r=_e([...n,...a]);let c={};return Object.entries(t).forEach((([t,e])=>{const[s,n]=Array.isArray(e)?e:[e,!1];c[t]=n?s:_e([r,s])})),c["*"]||(c["*"]=r),c}const xe=()=>t=>e=>t(e);function Ee(t=[],e=[],s={}){let n=[...e,...Object.entries(s).map((([t,e])=>function(t,e){return s=>e(Object.assign(Object.assign({},s),{getState:()=>B.get(t,s.getState())}))}(t,e)))],a=!1,r=t.flatMap((t=>t!==xe?t:(a=!0,n)));return a||(r=[...r,...n]),(t=>e=>s=>t.reduceRight(((t,s)=>s(e)(t)),s))(r)}function Ie(t,e){return s=>n=>{void 0===n&&(n=t);const a=e[s.type]||e["*"];return a?a(s.payload,s)(n):n}}function ke([t,e]){return e?Object.entries(B.mapValues((e=>s=>e(s[t])))(e)):[]}class Oe{constructor(t={}){var e,s,n,a,r,c,l,o;this.localSelectors={},this.localEffects=[],this.localActions={},this.localMutations={},this.localSubscriptions=[],this.localInitial=null!==(e=t.initial)&&void 0!==e?e:{},this.localSelectors=null!==(s=t.selectors)&&void 0!==s?s:{},this.coduxes=null!==(n=t.coduxes)&&void 0!==n?n:[],this.subduxes=null!==(a=t.subduxes)&&void 0!==a?a:{},Object.entries(null!==(r=t.actions)&&void 0!==r?r:{}).forEach((t=>this.addAction(...t))),this.coduxes.forEach((t=>Object.entries(t.actions).forEach((t=>this.addAction(...t))))),Object.values(this.subduxes).forEach((t=>{Object.entries(t.actions).forEach((t=>{this.addAction(...t)}))})),t.subscriptions&&t.subscriptions.forEach((t=>this.addSubscription(t))),this.groomMutations=null!==(c=t.groomMutations)&&void 0!==c?c:t=>t;let i=null!==(l=t.effects)&&void 0!==l?l:[];Array.isArray(i)||(i=Object.entries(i)),i.forEach((t=>this.addEffect(...t)));let u=null!==(o=t.mutations)&&void 0!==o?o:[];Array.isArray(u)||(u=B.toPairs(u)),u.forEach((t=>this.addMutation(...t)))}get initial(){return function(t,e=[],s={}){return B.isPlainObject(t)?B.flow([be(B.omit(["*"],s)),e.map((t=>be(t))),be(t)].flat())({}):t}(this.localInitial,this.coduxes.map((({initial:t})=>t)),B.mapValues("initial",this.subduxes))}get middleware(){const t=this.selectors,e=this.actions;return Ee(this.localEffects.map((s=>((t,e,s)=>{let[n,a,r]=t;if(a===xe)return xe;r&&(a=a());const c=t=>a(Object.assign(Object.assign({},t),{actions:e,selectors:s}));return"*"===n?c:t=>e=>s=>s.type!==n?e(s):c(t)(e)(s)})(s,e,t))),this.coduxes.map(B.get("middleware")),B.mapValues("middleware",this.subduxes))}get actions(){return this.localActions}get upreducer(){return Ie(this.initial,this.mutations)}get reducer(){return(t,e)=>this.upreducer(e)(t)}get mutations(){return we(this.localMutations,B.mapValues("upreducer",this.subduxes),B.map("upreducer",this.coduxes))}get subduxUpreducer(){return Ie(this.initial,we({},this.subduxes))}createStore(...t){const e=function(t,e,s={}){return function(n,a){let r=a?a(e):U(e);const c=z(t,n,r);return c.actions=s,c}}(this.reducer,this.middleware,this.actions)(...t);return function(t,e=[]){e.forEach((e=>{const s=e(t);let n=t.subscribe((()=>{const e=t.getState();return s(e,n)}))}))}(e,this.subscriptions),e}get subscriptions(){return[this.localSubscriptions,Object.entries(this.subduxes).map((([t,e])=>e.subscriptions.map((e=>function(t,e){return s=>{const n=e(s);return(e,s)=>n(B.get(t,e),s)}}(t,e)))))].flat(1/0).map((t=>function(t){return e=>{const s=t(e);let n;return(t,e)=>{if(t!==n)return n=t,s(t,e)}}}(t)))}get asDux(){return{createStore:this.createStore.bind(this),upreducer:this.upreducer,subduxes:this.subduxes,coduxes:this.coduxes,middleware:this.middleware,actions:this.actions,reducer:this.reducer,mutations:this.mutations,initial:this.initial,selectors:this.selectors,subscriptions:this.subscriptions}}addMutation(t,e,s){const n=this.addAction(t);this.localMutations[n.type]=[this.groomMutations(e),s]}addEffect(t,e,s=!1){const n=this.addAction(t);this.localEffects.push([n.type,e,s])}addAction(t,e){var s;let n,a;"string"==typeof t?(n=t,a=e?e.type?e:H(n,((...t)=>({payload:e(...t)}))):null!==(s=this.localActions[n])&&void 0!==s?s:H(n,G())):(n=t.type,a=t);const r=this.localActions[n];if(!r)return this.localActions[n]=a;if(r!==a&&"*"!==r.type)throw new Error(`action ${n} already exists`);return r}get _middlewareEntries(){const t=t=>B.groupBy((([,,t])=>["^","$"].includes(t)?t:"middle"),t),e=B.flow([B.toPairs,B.map((([t,e])=>e._middlewareEntries.map((([e,s,...n])=>[e,[t,...s],...n])))),B.flatten,t])(this.subduxes),s=t(this.localEffects.map((t=>[this,[],...t])));return B.flatten([s["^"],e["^"],s.middle,e.middle,e.$,s.$].filter((t=>t)))}addSelector(t,e){this.localSelectors[t]=e}get selectors(){return function(t={},e=[],s={}){return Object.fromEntries([Object.entries(s).flatMap(ke),Object.entries(e),Object.entries(t)].flat())}(this.localSelectors,B.map("selectors",this.coduxes),B.mapValues("selectors",this.subduxes))}addSubscription(t){this.localSubscriptions=[...this.localSubscriptions,t]}}const De=R("set_ftl",W()),Me=R("set_ftl_reqs",W());console.log(Oe);const Ae=new Oe({initial:{mass:0,cost:0,type:"none"}});Ae.addMutation(De,(t=>be.update({type:t}))),Ae.addMutation(Me,(t=>be.update(t)));var Pe=Ae.asDux;const Te=R("set_engine",W()),Ce=R("set_drive_reqs",W()),Se=new Oe({initial:{mass:1,cost:2,rating:1}});Se.addMutation(Te,(t=>be.update(t))),Se.addMutation(Ce,(t=>be.update(t)));var Ne=Se.asDux;function je(t){return"beam"===t.weapon_type?function({weapon_class:t,arcs:e}){let s;1===t&&(s=1);2==t&&(s=2+(e.length>3?1:0));3==t&&(s=4,Ve(e)?s+=2:s+=e.length-1);4==t&&(s=8,Ve(e)?s+=4:s+=2*(e.length-1));return{mass:s,cost:3*s}}(t):"submunition"==t.weapon_type||"pds"===t.weapon_type?{mass:1,cost:3}:"scattergun"===t.weapon_type?{mass:1,cost:4}:"needle"===t.weapon_type?{mass:2,cost:6}:{cost:0,mass:0}}const Ve=t=>4===t.length&&!t.some((t=>1===t.length));const qe=R("add_weapon",W()),Le=R("remove_weapon",W()),Fe=(Be=t=>be(je(t)),t=>Be(t)(t));var Be;const Ue=new Oe({initial:[]}),ze={beam:{weapon_type:"beam",weapon_class:1,arcs:["F","A","FS","FP","AS","AP"]},submunition:{weapon_type:"submunition",arcs:["F"]},pds:{weapon_type:"pds"},scattergun:{weapon_type:"scattergun"},needle:{weapon_type:"needle",arcs:["F"]}};Ue.addMutation(qe,(t=>e=>{const s=1+Math.max(0,...e.map((({id:t})=>t)));return[...e,o(l({},Fe(ze[t])),{id:s})]})),Ue.addMutation(Le,(t=>e=>e.filter((e=>e.id!==t))));const He=R("set_weapon",W());Ue.addMutation(He,(t=>be.map(be.if(Y({id:t.id}),(e=>Fe(be(t,e)))))));var Ge=Ue.asDux;const Re=new Oe({initial:{rating:0,cost:0,mass:0}});Re.addMutation(R("set_adfc",W()),(t=>be.update({rating:t,mass:2*t,cost:8*t})));var We=new Oe({initial:{firecons:{nbr:0,cost:0,mass:0}},subduxes:{weapons:Ge,adfc:Re.asDux}}).asDux;const Ye=[{name:"Scout",mass:[4,10],abbrev:"SC"},{name:"Courier",mass:[4,10],abbrev:"SC"},{name:"Corvette",mass:[8,16],abbrev:"CT"},{name:"Frigate",mass:[14,28],abbrev:"FF"},{name:"Destroyer",mass:[24,36],abbrev:"DD"},{name:"Heavy Destroyer",mass:[30,40],abbrev:"DH"},{name:"Light Cruiser",mass:[40,60],abbrev:"CL"},{name:"Patrol",mass:[50,70],abbrev:"CE"},{name:"Escort Cruiser",mass:[50,70],abbrev:"CE"},{name:"Heavy Cruiser",mass:[60,90],abbrev:"CA"},{name:"Battlecruiser",mass:[80,110],abbrev:"BC"},{name:"Battleship",mass:[100,140],abbrev:"BB"},{name:"Heavy Battleship",mass:[120,160],abbrev:"BDN"},{name:"Dreadnought",mass:[140,180],abbrev:"DN"},{name:"Superdreadnought",mass:[160,300],abbrev:"SDN"},{name:"Escort Carrier",mass:[60,140],abbrev:"CVE",carrier:!0},{name:"Light Carrier",mass:[120,180],abbrev:"CVL",carrier:!0},{name:"Heavy Carrier",mass:[160,300],abbrev:"CVH",carrier:!0},{name:"Attack Carrier",mass:[150,300],abbrev:"CVA",carrier:!0}];function Je(t=0,e=!1){return console.log({carrier:e}),Ye.filter((t=>e==!!t.carrier)).filter((e=>e.mass[0]<=t)).filter((e=>e.mass[1]>=t))}const Ze=new Oe({initial:{standard:0,advanced:0,cost:0,mass:0}}),Xe=R("set_screens",W());Ze.addMutation(Xe,(t=>be.update(t)));const Ke=R("set_screens_reqs",W());Ze.addMutation(Ke,(t=>be.update(t)));var Qe=Ze.asDux;const ts=new Oe({initial:[]}),es=R("set_armour_nbr_layers",W());ts.addMutation(es,(t=>e=>(e.length>t&&(e=e.slice(0,t)),e.length[]))].flat()),e=be.map(((t,e)=>l({layer:e+1,rating:0,cost:0,mass:0},t)),e)))),ts.addMutation(R("set_armour_layer",W()),(({layer:t,rating:e})=>be.map(be.if(J.matches({layer:t}),be({rating:e,cost:2*t*e,mass:2*e})))));var ss=ts.asDux;var ns=new Oe({initial:{mass:0,cost:0,hull:{rating:1,advanced:!1,cost:2,mass:1}},subduxes:{screens:Qe,armour:ss}}).asDux;const as=new Oe({initial:{space:0,cost:0,mass:0}}),rs=R("set_cargo",W());as.addMutation(rs,(t=>()=>({space:t,cost:0,mass:t})));var cs=as.asDux;const ls=new Oe({initial:{type:"none",cost:0,mass:0}}),os=R("set_streamlining",W());ls.addMutation(os,(t=>be.update({type:t})));const is=R("set_streamlining_cost_mass",W());ls.addMutation(is,(t=>be.update(t)));var us=ls.asDux,$s=[{type:"standard",cost:3},{type:"fast",cost:4},{type:"heavy",cost:5},{type:"interceptor",cost:3},{type:"attack",cost:4},{type:"long range",cost:4},{type:"torpedo",cost:6}];const hs=new Oe({initial:{bays:0,cost:0,mass:0,squadrons:[]}}),fs=R("set_squadron",W());hs.addMutation(fs,(({id:t,type:e})=>be.update({squadrons:be.map(be.if(J.matches({id:t}),be({type:e,cost:6*J.find($s,{type:e}).cost,mass:6})))})));const ps=R("set_carrier_bays",W());hs.addMutation(ps,(t=>e=>((e=be.update({bays:t,mass:9*t,cost:27*t})(e)).squadrons.length>t&&(e=be.update({squadrons:e=>e.slice(0,t)},e)),e.squadrons.length[...s,...J.times(t-e.squadrons.length,(t=>({id:1+t+e.squadrons.length,cost:6*$s[0].cost,mass:6,type:$s[0].type})))]},e)),e)));var ds=hs.asDux;const ms=R("set_ship_mass",W()),gs=R("set_name",W()),vs=R("set_ship_reqs",W()),ys=R("set_hull",W()),bs=R("set_ship_type",W()),_s=R("reset"),ws={general:{ship_class:"",name:"",ship_type:"",mass:10,used_mass:0,cost:10}};console.log(Oe);const xs=new Oe({subduxes:{ftl:Pe,engine:Ne,weaponry:We,structure:ns,cargo:cs,streamlining:us,carrier:ds},initial:ws});xs.addMutation(_s,(()=>()=>ws)),xs.addMutation(ys,(({rating:t})=>e=>be.updateIn("structure.hull",{cost:2*t,rating:t,mass:t})(e))),xs.addMutation(ms,(t=>be.updateIn("general",{mass:t}))),xs.addMutation(gs,(t=>be.updateIn("general",{name:t}))),xs.addMutation(R("set_ship_class",W()),(t=>be.updateIn("general",{ship_class:t}))),xs.addMutation(vs,(({cost:t,mass:e})=>be.updateIn("general",{cost:t,used_mass:e}))),xs.addSubscription((t=>Z(Gt,(e=>t.dispatch(vs(e)))))),xs.addSubscription((t=>Z((t=>t.general.mass),(t=>t.streamlining.type),((e,s)=>{const n=Rt(e*("none"===s?0:"partial"===s?5:10)/100),a=2*n;t.dispatch(xs.actions.set_streamlining_cost_mass({cost:a,mass:n}))})))),xs.addSubscription((t=>Z((t=>t.general.mass),(t=>t.general.ship_type),(t=>t.carrier.bays),((e,s,n)=>{console.log({bays:n});const a=Je(e,n>0);console.log({candidates:a}),0!==a.length&&(a.find((({name:t})=>t===s))||t.dispatch(t.actions.set_ship_type(a[0].name)))})))),xs.addMutation(bs,(t=>be.updateIn("general.ship_type",t))),xs.addSubscription((t=>Z([t=>t.general.mass,t=>t.ftl.type],((e,s)=>t.dispatch(Pe.actions.set_ftl_reqs(function(t,e){if("none"===t)return{cost:0,mass:0};const s=Math.ceil(e/10);return{mass:s,cost:s*("advanced"===t?3:2)}}(s,e))))))),xs.addSubscription((t=>Z((t=>t.general.mass),(t=>t.structure.screens.standard),(t=>t.structure.screens.advanced),((e,s,n)=>{console.log({mass:e,standard:s,advanced:n});const a=s*Math.max(3,Rt(.05*e)),r=n*Math.max(4,Rt(.075*e));t.dispatch(xs.actions.set_screens_reqs({mass:a+r,cost:3*a+4*r}))})))),xs.addSubscription((t=>Z([t=>t.general.mass,t=>t.engine.rating,t=>t.engine.advanced],((e,s,n)=>t.dispatch(xs.actions.set_drive_reqs(function(t,e,s=!1){const n=Math.ceil(.05*e*t);return{mass:n,cost:n*(s?3:2)}}(e,s,n)))))));const Es=R("set_firecons",W());xs.addMutation(Es,(t=>be.updateIn("weaponry.firecons",l({nbr:t},(t=>({cost:4*t,mass:t}))(t)))));var Is=xs.asDux;xs.actions;let ks=Q;ks=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;function Os(t){let e,s,n,a,r,c;return{c(){e=h("aside"),s=h("pre"),n=h("code"),a=f(t[0]),this.h()},l(r){e=d(r,"ASIDE",{class:!0});var c=m(e);s=d(c,"PRE",{class:!0});var l=m(s);n=d(l,"CODE",{});var o=m(n);a=g(o,t[0]),o.forEach(v),l.forEach(v),c.forEach(v),this.h()},h(){b(s,"class","svelte-2g9858"),b(e,"class","svelte-2g9858")},m(t,r){_(t,e,r),w(e,s),w(s,n),w(n,a),c=!0},p(t,[e]){(!c||1&e)&&tt(a,t[0])},i(t){c||(et((()=>{r||(r=st(e,nt,{},!0)),r.run(1)})),c=!0)},o(t){r||(r=st(e,nt,{},!1)),r.run(0),c=!1},d(t){t&&v(e),t&&r&&r.end()}}}function Ds(t,e,s){let n,{ship:a={}}=e;return at(),t.$$set=t=>{"ship"in t&&s(1,a=t.ship)},t.$$.update=()=>{2&t.$$.dirty&&s(0,n=JSON.stringify(a,null,2))},[n,a]}class Ms extends i{constructor(t){super(),u(this,t,Ds,Os,$,{ship:1})}}function As(t){let e,s;return{c(){e=h("div"),s=f(t[0]),this.h()},l(n){e=d(n,"DIV",{class:!0});var a=m(e);s=g(a,t[0]),a.forEach(v),this.h()},h(){b(e,"class","svelte-1oeefsn")},m(t,n){_(t,e,n),w(e,s)},p(t,[e]){1&e&&tt(s,t[0])},i:x,o:x,d(t){t&&v(e)}}}function Ps(t,e,s){let{cost:n=0}=e;return t.$$set=t=>{"cost"in t&&s(0,n=t.cost)},[n]}class Ts extends i{constructor(t){super(),u(this,t,Ps,As,$,{cost:0})}}function Cs(t){let e,s;return{c(){e=h("div"),s=f(t[0]),this.h()},l(n){e=d(n,"DIV",{class:!0});var a=m(e);s=g(a,t[0]),a.forEach(v),this.h()},h(){b(e,"class","svelte-ylboiy")},m(t,n){_(t,e,n),w(e,s)},p(t,[e]){1&e&&tt(s,t[0])},i:x,o:x,d(t){t&&v(e)}}}function Ss(t,e,s){let{mass:n=0}=e;return t.$$set=t=>{"mass"in t&&s(0,n=t.mass)},[n]}class Ns extends i{constructor(t){super(),u(this,t,Ss,Cs,$,{mass:0})}}function js(t){let e,s,n,a,r,c,l,o,i,u,$,x,E,I,k;return x=new Ts({props:{cost:t[2]}}),I=new Ns({props:{mass:t[3]}}),{c(){e=h("h1"),s=f("ship name: "),n=h("div"),a=p(),r=h("div"),c=h("h2"),l=f(t[0]),o=f("-class, "),i=f(t[1]),u=p(),$=h("div"),rt(x.$$.fragment),E=f("\n  \n "),rt(I.$$.fragment),this.h()},l(h){e=d(h,"H1",{class:!0});var f=m(e);s=g(f,"ship name: "),n=d(f,"DIV",{class:!0}),m(n).forEach(v),f.forEach(v),a=y(h),r=d(h,"DIV",{class:!0});var p=m(r);c=d(p,"H2",{class:!0});var b=m(c);l=g(b,t[0]),o=g(b,"-class, "),i=g(b,t[1]),b.forEach(v),u=y(p),$=d(p,"DIV",{class:!0});var _=m($);ct(x.$$.fragment,_),E=g(_,"\n  \n "),ct(I.$$.fragment,_),_.forEach(v),p.forEach(v),this.h()},h(){b(n,"class","fill svelte-bo35k"),b(e,"class","svelte-bo35k"),b(c,"class","svelte-bo35k"),b($,"class","reqs svelte-bo35k"),b(r,"class","details svelte-bo35k")},m(t,h){_(t,e,h),w(e,s),w(e,n),_(t,a,h),_(t,r,h),w(r,c),w(c,l),w(c,o),w(c,i),w(r,u),w(r,$),lt(x,$,null),w($,E),lt(I,$,null),k=!0},p(t,[e]){(!k||1&e)&&tt(l,t[0]),(!k||2&e)&&tt(i,t[1]);const s={};4&e&&(s.cost=t[2]),x.$set(s);const n={};8&e&&(n.mass=t[3]),I.$set(n)},i(t){k||(ot(x.$$.fragment,t),ot(I.$$.fragment,t),k=!0)},o(t){it(x.$$.fragment,t),it(I.$$.fragment,t),k=!1},d(t){t&&v(e),t&&v(a),t&&v(r),ut(x),ut(I)}}}function Vs(t,e,s){let{ship_class:n}=e,{ship_type:a}=e,{cost:r}=e,{mass:c=0}=e;return t.$$set=t=>{"ship_class"in t&&s(0,n=t.ship_class),"ship_type"in t&&s(1,a=t.ship_type),"cost"in t&&s(2,r=t.cost),"mass"in t&&s(3,c=t.mass)},[n,a,r,c]}class qs extends i{constructor(t){super(),u(this,t,Vs,js,$,{ship_class:0,ship_type:1,cost:2,mass:3})}}function Ls(t){let e,s;return{c(){e=h("img"),this.h()},l(t){e=d(t,"IMG",{class:!0,src:!0,alt:!0}),this.h()},h(){b(e,"class","ftl svelte-w7le23"),e.src!==(s="icons/ftl-drive.svg")&&b(e,"src","icons/ftl-drive.svg"),b(e,"alt","ftl drive")},m(t,s){_(t,e,s)},d(t){t&&v(e)}}}function Fs(t){let e,s;return{c(){e=h("div"),s=f(t[1]),this.h()},l(n){e=d(n,"DIV",{class:!0});var a=m(e);s=g(a,t[1]),a.forEach(v),this.h()},h(){b(e,"class","thrust svelte-w7le23")},m(t,n){_(t,e,n),w(e,s)},p(t,e){2&e&&tt(s,t[1])},d(t){t&&v(e)}}}function Bs(t){let e,s,n,a,r,c="none"!==t[0]&&Ls(),l=t[1]>0&&Fs(t);return{c(){e=h("div"),c&&c.c(),s=p(),l&&l.c(),n=p(),a=h("img"),this.h()},l(t){e=d(t,"DIV",{class:!0});var r=m(e);c&&c.l(r),s=y(r),l&&l.l(r),n=y(r),a=d(r,"IMG",{class:!0,src:!0,alt:!0}),r.forEach(v),this.h()},h(){b(a,"class","internal svelte-w7le23"),a.src!==(r="icons/internal-systems.svg")&&b(a,"src","icons/internal-systems.svg"),b(a,"alt","internal systems"),b(e,"class","main_systems svelte-w7le23")},m(t,r){_(t,e,r),c&&c.m(e,null),w(e,s),l&&l.m(e,null),w(e,n),w(e,a)},p(t,[a]){"none"!==t[0]?c||(c=Ls(),c.c(),c.m(e,s)):c&&(c.d(1),c=null),t[1]>0?l?l.p(t,a):(l=Fs(t),l.c(),l.m(e,n)):l&&(l.d(1),l=null)},i:x,o:x,d(t){t&&v(e),c&&c.d(),l&&l.d()}}}function Us(t,e,s){let{ftl:n="none"}=e,{engine:a=0}=e;return t.$$set=t=>{"ftl"in t&&s(0,n=t.ftl),"engine"in t&&s(1,a=t.engine)},[n,a]}class zs extends i{constructor(t){super(),u(this,t,Us,Bs,$,{ftl:0,engine:1})}}function Hs(t,e,s){const n=t.slice();return n[7]=e[s],n[9]=s,n}function Gs(t,e,s){const n=t.slice();return n[10]=e[s],n[12]=s,n}function Rs(t){let e,s;return{c(){e=h("img"),this.h()},l(t){e=d(t,"IMG",{src:!0,alt:!0,class:!0}),this.h()},h(){e.src!==(s="icons/crew-star.svg")&&b(e,"src","icons/crew-star.svg"),b(e,"alt","crew loss threshold"),b(e,"class","svelte-qekx9g")},m(t,s){_(t,e,s)},d(t){t&&v(e)}}}function Ws(t,e){let s,n=e[10]&&Rs();return{key:t,first:null,c(){s=h("div"),n&&n.c(),this.h()},l(t){s=d(t,"DIV",{class:!0});var e=m(s);n&&n.l(e),e.forEach(v),this.h()},h(){b(s,"class","cell svelte-qekx9g"),this.first=s},m(t,e){_(t,s,e),n&&n.m(s,null)},p(t,a){(e=t)[10]?n||(n=Rs(),n.c(),n.m(s,null)):n&&(n.d(1),n=null)},d(t){t&&v(s),n&&n.d()}}}function Ys(t,e){let s,n,a=[],r=new Map,c=e[7];const l=t=>t[12];for(let o=0;ot[9];for(let c=0;c{"ship_mass"in t&&s(1,c=t.ship_mass),"rating"in t&&s(2,l=t.rating),"advanced"in t&&s(3,o=t.advanced)},t.$$.update=()=>{8&t.$$.dirty&&s(4,n=o?3:4),4&t.$$.dirty&&s(5,a=Array(l).fill(!1)),2&t.$$.dirty&&s(6,r=Rt(c/20)),96&t.$$.dirty&&s(5,a=Zs(a,r).map((t=>(t[t.length-1]=!0,t))).flat()),48&t.$$.dirty&&s(0,i=Zs(a,n))},[i,c,l,o,n,a,r]}class Ks extends i{constructor(t){super(),u(this,t,Xs,Js,$,{ship_mass:1,rating:2,advanced:3})}}function Qs(t,e,s){const n=t.slice();return n[1]=e[s],n}function tn(t,e,s){const n=t.slice();return n[4]=e[s],n}function en(t,e){let s;return{key:t,first:null,c(){s=h("div"),this.h()},l(t){s=d(t,"DIV",{class:!0}),m(s).forEach(v),this.h()},h(){b(s,"class","cell svelte-15e5q3d"),this.first=s},m(t,e){_(t,s,e)},p(t,e){},d(t){t&&v(s)}}}function sn(t,e){let s,n,a=[],r=new Map,c=J.range(e[1].rating);const l=t=>t[4];for(let o=0;ot[1];for(let c=0;c{"armour"in t&&s(0,n=t.armour)},t.$$.update=()=>{1&t.$$.dirty&&console.log(n)},[n]}class rn extends i{constructor(t){super(),u(this,t,an,nn,$,{armour:0})}}function cn(t){let e,s,n,a,r;return s=new rn({props:{armour:t[0].armour}}),a=new Ks({props:{rating:t[0].hull.rating,advanced:t[0].hull.advanced,ship_mass:t[1]}}),{c(){e=h("div"),rt(s.$$.fragment),n=p(),rt(a.$$.fragment)},l(t){e=d(t,"DIV",{});var r=m(e);ct(s.$$.fragment,r),n=y(r),ct(a.$$.fragment,r),r.forEach(v)},m(t,c){_(t,e,c),lt(s,e,null),w(e,n),lt(a,e,null),r=!0},p(t,[e]){const n={};1&e&&(n.armour=t[0].armour),s.$set(n);const r={};1&e&&(r.rating=t[0].hull.rating),1&e&&(r.advanced=t[0].hull.advanced),2&e&&(r.ship_mass=t[1]),a.$set(r)},i(t){r||(ot(s.$$.fragment,t),ot(a.$$.fragment,t),r=!0)},o(t){it(s.$$.fragment,t),it(a.$$.fragment,t),r=!1},d(t){t&&v(e),ut(s),ut(a)}}}function ln(t,e,s){let{structure:n={}}=e,{ship_mass:a=0}=e;return t.$$set=t=>{"structure"in t&&s(0,n=t.structure),"ship_mass"in t&&s(1,a=t.ship_mass)},[n,a]}class on extends i{constructor(t){super(),u(this,t,ln,cn,$,{structure:0,ship_mass:1})}}function un(t){let e,s,n,a;return{c(){e=E("g"),s=E("path"),this.h()},l(t){e=d(t,"g",{transform:!0},1);var n=m(e);s=d(n,"path",{d:!0,class:!0},1),m(s).forEach(v),n.forEach(v),this.h()},h(){b(s,"d",t[1]),b(s,"class","svelte-7q6uh5"),ft(s,"active",t[0]),b(e,"transform",t[2])},m(r,c){_(r,e,c),w(e,s),n||(a=pt(s,"click",t[7]),n=!0)},p(t,[n]){2&n&&b(s,"d",t[1]),1&n&&ft(s,"active",t[0]),4&n&&b(e,"transform",t[2])},i:x,o:x,d(t){t&&v(e),n=!1,a()}}}function $n(t,e,s){let{arc:n}=e,{radius:a}=e,{active:r=!1}=e;const c={F:0,FS:300,AS:240,A:180,AP:120,FP:60};let l,o,i,u;return t.$$set=t=>{"arc"in t&&s(3,n=t.arc),"radius"in t&&s(4,a=t.radius),"active"in t&&s(0,r=t.active)},t.$$.update=()=>{16&t.$$.dirty&&s(5,l=Math.round(a*(1-Math.sin(60/180*Math.PI)))),16&t.$$.dirty&&s(6,o=Math.round(a*Math.cos(60/180*Math.PI))),112&t.$$.dirty&&s(1,i=`M ${a},${a} L ${a-o},${l} A ${a},${a} 0 0 1 ${a+o},${l} Z`),24&t.$$.dirty&&s(2,u=`rotate(${c[n]},${a},${a})`)},[r,i,u,n,a,l,o,function(e){dt(t,e)}]}class hn extends i{constructor(t){super(),u(this,t,$n,un,$,{arc:3,radius:4,active:0})}}function fn(t,e,s){const n=t.slice();return n[8]=e[s],n}function pn(t,e){let s,n,a;return n=new hn({props:{arc:e[8],radius:e[1]/2,active:e[0].includes(e[8])}}),n.$on("click",(function(){return e[6](e[8])})),{key:t,first:null,c(){s=mt(),rt(n.$$.fragment),this.h()},l(t){s=mt(),ct(n.$$.fragment,t),this.h()},h(){this.first=s},m(t,e){_(t,s,e),lt(n,t,e),a=!0},p(t,s){e=t;const a={};2&s&&(a.radius=e[1]/2),1&s&&(a.active=e[0].includes(e[8])),n.$set(a)},i(t){a||(ot(n.$$.fragment,t),a=!0)},o(t){it(n.$$.fragment,t),a=!1},d(t){t&&v(s),ut(n,t)}}}function dn(t){let e,s,n,a,r,c,l=[],o=new Map,i=t[2];const u=t=>t[8];for(let f=0;fl("click_arc",t);return t.$$set=t=>{"selected"in t&&s(0,r=t.selected),"size"in t&&s(1,c=t.size),"$$scope"in t&&s(4,a=t.$$scope)},[r,c,["FS","F","FP","AP","A","AS"],o,a,n,t=>o(t)]}class gn extends i{constructor(t){super(),u(this,t,mn,dn,$,{selected:0,size:1})}}function vn(t){let e,s;return{c(){e=E("text"),s=f(t[0]),this.h()},l(n){e=d(n,"text",{x:!0,y:!0,class:!0},1);var a=m(e);s=g(a,t[0]),a.forEach(v),this.h()},h(){b(e,"x","50%"),b(e,"y","50%"),b(e,"class","svelte-1u8rlr5")},m(t,n){_(t,e,n),w(e,s)},p(t,e){1&e&&tt(s,t[0])},d(t){t&&v(e)}}}function yn(t){let e,s,n;return s=new gn({props:{selected:t[1],size:"40",$$slots:{default:[vn]},$$scope:{ctx:t}}}),{c(){e=h("div"),rt(s.$$.fragment),this.h()},l(t){e=d(t,"DIV",{class:!0});var n=m(e);ct(s.$$.fragment,n),n.forEach(v),this.h()},h(){b(e,"class","svelte-1u8rlr5")},m(t,a){_(t,e,a),lt(s,e,null),n=!0},p(t,[e]){const n={};2&e&&(n.selected=t[1]),5&e&&(n.$$scope={dirty:e,ctx:t}),s.$set(n)},i(t){n||(ot(s.$$.fragment,t),n=!0)},o(t){it(s.$$.fragment,t),n=!1},d(t){t&&v(e),ut(s)}}}function bn(t,e,s){let{weapon_class:n=1}=e,{arcs:a=[]}=e;return t.$$set=t=>{"weapon_class"in t&&s(0,n=t.weapon_class),"arcs"in t&&s(1,a=t.arcs)},[n,a]}class _n extends i{constructor(t){super(),u(this,t,bn,yn,$,{weapon_class:0,arcs:1})}}function wn(t,e,s){const n=t.slice();return n[2]=e[s],n}function xn(t){let e,s;const n=[t[2]];let a={};for(let r=0;rit(r[t],1,1,(()=>{r[t]=null}));return{c(){e=h("div"),s=h("div");for(let t=0;t{"weapons"in t&&s(1,n=t.weapons)},t.$$.update=()=>{2&t.$$.dirty&&s(0,a=n.filter((({weapon_type:t})=>"beam"===t)))},[a,n]}class kn extends i{constructor(t){super(),u(this,t,In,En,$,{weapons:1})}}function On(t,e,s){const n=t.slice();return n[1]=e[s],n}function Dn(t){let e,s;return{c(){e=h("img"),this.h()},l(t){e=d(t,"IMG",{class:!0,src:!0,alt:!0}),this.h()},h(){b(e,"class","firecon svelte-d2fjdl"),e.src!==(s="icons/firecon.svg")&&b(e,"src","icons/firecon.svg"),b(e,"alt","firecon")},m(t,s){_(t,e,s)},d(t){t&&v(e)}}}function Mn(t){let e,s=J.range(t[0]),n=[];for(let a=0;a{"firecons"in t&&s(0,n=t.firecons)},[n]}class Pn extends i{constructor(t){super(),u(this,t,An,Mn,$,{firecons:0})}}function Tn(t,e,s){const n=t.slice();return n[2]=e[s],n}function Cn(t,e,s){const n=t.slice();return n[2]=e[s],n}function Sn(t){let e,s;return{c(){e=h("img"),this.h()},l(t){e=d(t,"IMG",{src:!0,alt:!0,class:!0}),this.h()},h(){e.src!==(s="icons/screen.svg")&&b(e,"src","icons/screen.svg"),b(e,"alt","screen"),b(e,"class","svelte-kh7po5")},m(t,s){_(t,e,s)},d(t){t&&v(e)}}}function Nn(t){let e,s;return{c(){e=h("img"),this.h()},l(t){e=d(t,"IMG",{src:!0,alt:!0,class:!0}),this.h()},h(){e.src!==(s="icons/screen-advanced.svg")&&b(e,"src","icons/screen-advanced.svg"),b(e,"alt","advanced screen"),b(e,"class","svelte-kh7po5")},m(t,s){_(t,e,s)},d(t){t&&v(e)}}}function jn(t){let e,s,n=J.range(t[0]),a=[];for(let l=0;l{"standard"in t&&s(0,n=t.standard),"advanced"in t&&s(1,a=t.advanced)},[n,a]}class qn extends i{constructor(t){super(),u(this,t,Vn,jn,$,{standard:0,advanced:1})}}function Ln(t){let e,s,n,a,r;s=new Pn({props:{firecons:t[0]}});const c=[t[1]];let l={};for(let o=0;o{"firecons"in t&&s(0,n=t.firecons),"screens"in t&&s(1,a=t.screens)},[n,a]}class Bn extends i{constructor(t){super(),u(this,t,Fn,Ln,$,{firecons:0,screens:1})}}function Un(t){let e,s,n,a,r,c,l,o,i,u,$,f,g;const x=[t[0].general];let E={};for(let h=0;h{f||(f=st(e,nt,{},!0)),f.run(1)})),g=!0)},o(t){it(s.$$.fragment,t),it(a.$$.fragment,t),it(l.$$.fragment,t),it(i.$$.fragment,t),it($.$$.fragment,t),f||(f=st(e,nt,{},!1)),f.run(0),g=!1},d(t){t&&v(e),ut(s),ut(a),ut(l),ut(i),ut($),t&&f&&f.end()}}}function zn(t,e,s){let{ship:n}=e;return t.$$set=t=>{"ship"in t&&s(0,n=t.ship)},[n]}class Hn extends i{constructor(t){super(),u(this,t,zn,Un,$,{ship:0})}}function Gn(t){let e,s;return{c(){e=h("label"),s=f(t[0]),this.h()},l(n){e=d(n,"LABEL",{class:!0});var a=m(e);s=g(a,t[0]),a.forEach(v),this.h()},h(){b(e,"class","svelte-1urp5hr")},m(t,n){_(t,e,n),w(e,s)},p(t,e){1&e&&tt(s,t[0])},d(t){t&&v(e)}}}function Rn(t){let e,s,n,a=t[0]&&Gn(t);const r=t[4].default,c=gt(r,t,t[3],null),l=c||function(t){let e,s,n;return{c(){e=h("input"),this.h()},l(t){e=d(t,"INPUT",{type:!0,placeholder:!0,value:!0}),this.h()},h(){b(e,"type","text"),b(e,"placeholder",t[2]),e.value=t[1]},m(a,r){_(a,e,r),s||(n=pt(e,"change",t[5]),s=!0)},p(t,s){4&s&&b(e,"placeholder",t[2]),2&s&&e.value!==t[1]&&(e.value=t[1])},d(t){t&&v(e),s=!1,n()}}}(t);return{c(){e=h("div"),a&&a.c(),s=p(),l&&l.c(),this.h()},l(t){e=d(t,"DIV",{class:!0});var n=m(e);a&&a.l(n),s=y(n),l&&l.l(n),n.forEach(v),this.h()},h(){b(e,"class","svelte-1urp5hr")},m(t,r){_(t,e,r),a&&a.m(e,null),w(e,s),l&&l.m(e,null),n=!0},p(t,[o]){t[0]?a?a.p(t,o):(a=Gn(t),a.c(),a.m(e,s)):a&&(a.d(1),a=null),c?c.p&&(!n||8&o)&&_t(c,r,t,t[3],o,null,null):l&&l.p&&6&o&&l.p(t,o)},i(t){n||(ot(l,t),n=!0)},o(t){it(l,t),n=!1},d(t){t&&v(e),a&&a.d(),l&&l.d(t)}}}function Wn(t,e,s){let{$$slots:n={},$$scope:a}=e,{label:r=""}=e,{value:c=""}=e,{placeholder:l}=e;return t.$$set=t=>{"label"in t&&s(0,r=t.label),"value"in t&&s(1,c=t.value),"placeholder"in t&&s(2,l=t.placeholder),"$$scope"in t&&s(3,a=t.$$scope)},[r,c,l,a,n,function(e){dt(t,e)}]}class Yn extends i{constructor(t){super(),u(this,t,Wn,Rn,$,{label:0,value:1,placeholder:2})}}function Jn(t,e,s){const n=t.slice();return n[7]=e[s],n}function Zn(t,e){let s,n,a,r=e[7]+"";return{key:t,first:null,c(){s=h("option"),n=f(r),this.h()},l(t){s=d(t,"OPTION",{value:!0});var e=m(s);n=g(e,r),e.forEach(v),this.h()},h(){s.__value=a=e[7],s.value=s.__value,this.first=s},m(t,e){_(t,s,e),w(s,n)},p(t,c){e=t,8&c&&r!==(r=e[7]+"")&&tt(n,r),8&c&&a!==(a=e[7])&&(s.__value=a,s.value=s.__value)},d(t){t&&v(s)}}}function Xn(t){let e,s,n,a=[],r=new Map,c=t[3];const l=t=>t[7];for(let o=0;o(a(),a=Ot(l,(t=>s(6,n=t))),l);t.$$.on_destroy.push((()=>a()));let c,{ship:l=kt("ship")}=e;r();let o;let i;return t.$$set=t=>{"ship"in t&&r(s(0,l=t.ship))},t.$$.update=()=>{64&t.$$.dirty&&s(1,c=n.general),64&t.$$.dirty&&s(2,o=n.general.ship_type),64&t.$$.dirty&&s(3,i=Je(n.general.mass,n.carrier.bays>0).map((({name:t})=>t)))},[l,c,o,i,t=>l.dispatch(l.actions.set_ship_class(t.target.value)),({target:{value:t}})=>l.dispatch.set_ship_type(t),n]}class ta extends i{constructor(t){super(),u(this,t,Qn,Kn,$,{ship:0})}}function ea(t){let e,s,n=-t[1]+"";return{c(){e=f("excessive mass: "),s=f(n)},l(t){e=g(t,"excessive mass: "),s=g(t,n)},m(t,n){_(t,e,n),_(t,s,n)},p(t,e){2&e&&n!==(n=-t[1]+"")&&tt(s,n)},d(t){t&&v(e),t&&v(s)}}}function sa(t){let e,s;return{c(){e=f("mass unused: "),s=f(t[1])},l(n){e=g(n,"mass unused: "),s=g(n,t[1])},m(t,n){_(t,e,n),_(t,s,n)},p(t,e){2&e&&tt(s,t[1])},d(t){t&&v(e),t&&v(s)}}}function na(t){let e,s,n,a,r,c,l,o;function i(t,e){return t[3]?sa:ea}let u=i(t),$=u(t);return{c(){e=h("input"),n=p(),a=h("span"),r=p(),c=h("div"),$.c(),this.h()},l(t){e=d(t,"INPUT",{value:!0,type:!0,min:!0,max:!0,class:!0}),n=y(t),a=d(t,"SPAN",{class:!0}),m(a).forEach(v),r=y(t),c=d(t,"DIV",{class:!0});var s=m(c);$.l(s),s.forEach(v),this.h()},h(){e.value=s=t[2].general.mass,b(e,"type","number"),b(e,"min","10"),b(e,"max","300"),b(e,"class","svelte-1lxxcoi"),b(a,"class","mass_symbol svelte-1lxxcoi"),b(c,"class","note svelte-1lxxcoi"),ft(c,"warning",!t[3])},m(s,i){_(s,e,i),_(s,n,i),_(s,a,i),_(s,r,i),_(s,c,i),$.m(c,null),l||(o=pt(e,"change",t[4]),l=!0)},p(t,n){4&n&&s!==(s=t[2].general.mass)&&(e.value=s),u===(u=i(t))&&$?$.p(t,n):($.d(1),$=u(t),$&&($.c(),$.m(c,null))),8&n&&ft(c,"warning",!t[3])},d(t){t&&v(e),t&&v(n),t&&v(a),t&&v(r),t&&v(c),$.d(),l=!1,o()}}}function aa(t){let e,s,n=t[2].general.cost+"";return{c(){e=h("span"),s=f(n),this.h()},l(t){e=d(t,"SPAN",{class:!0});var a=m(e);s=g(a,n),a.forEach(v),this.h()},h(){b(e,"class","cost svelte-1lxxcoi")},m(t,n){_(t,e,n),w(e,s)},p(t,e){4&e&&n!==(n=t[2].general.cost+"")&&tt(s,n)},d(t){t&&v(e)}}}function ra(t){let e,s,n,a,r,c;return s=new Yn({props:{label:"ship tonnage",$$slots:{default:[na]},$$scope:{ctx:t}}}),r=new Yn({props:{label:"cost",$$slots:{default:[aa]},$$scope:{ctx:t}}}),{c(){e=h("div"),rt(s.$$.fragment),n=p(),a=h("div"),rt(r.$$.fragment),this.h()},l(t){e=d(t,"DIV",{class:!0});var c=m(e);ct(s.$$.fragment,c),c.forEach(v),n=y(t),a=d(t,"DIV",{class:!0});var l=m(a);ct(r.$$.fragment,l),l.forEach(v),this.h()},h(){b(e,"class","mass svelte-1lxxcoi"),b(a,"class","cost svelte-1lxxcoi")},m(t,l){_(t,e,l),lt(s,e,null),_(t,n,l),_(t,a,l),lt(r,a,null),c=!0},p(t,[e]){const n={};46&e&&(n.$$scope={dirty:e,ctx:t}),s.$set(n);const a={};36&e&&(a.$$scope={dirty:e,ctx:t}),r.$set(a)},i(t){c||(ot(s.$$.fragment,t),ot(r.$$.fragment,t),c=!0)},o(t){it(s.$$.fragment,t),it(r.$$.fragment,t),c=!1},d(t){t&&v(e),ut(s),t&&v(n),t&&v(a),ut(r)}}}function ca(t,e,s){let n,a=x,r=()=>(a(),a=Ot(c,(t=>s(2,n=t))),c);t.$$.on_destroy.push((()=>a()));let{ship:c=kt("ship")}=e;r();let l,o=!0;return t.$$set=t=>{"ship"in t&&r(s(0,c=t.ship))},t.$$.update=()=>{4&t.$$.dirty&&s(1,l=n.general.mass-n.general.used_mass),2&t.$$.dirty&&s(3,o=l>=0)},[c,l,n,o,({target:{value:t}})=>c.dispatch(c.actions.set_ship_mass(parseInt(t)))]}class la extends i{constructor(t){super(),u(this,t,ca,ra,$,{ship:0})}}function oa(t){let e,s,n,a;return e=new ta({}),n=new la({}),{c(){rt(e.$$.fragment),s=p(),rt(n.$$.fragment)},l(t){ct(e.$$.fragment,t),s=y(t),ct(n.$$.fragment,t)},m(t,r){lt(e,t,r),_(t,s,r),lt(n,t,r),a=!0},p:x,i(t){a||(ot(e.$$.fragment,t),ot(n.$$.fragment,t),a=!0)},o(t){it(e.$$.fragment,t),it(n.$$.fragment,t),a=!1},d(t){ut(e,t),t&&v(s),ut(n,t)}}}class ia extends i{constructor(t){super(),u(this,t,null,oa,$,{})}}function ua(t){let e,s,n,a,r,c,l,o,i,u,$,E,I,k,O,D,M,A,P,T,C,S,N,j,V,q,L,F,B,U,z,H,G;return{c(){e=h("aside"),s=h("div"),n=h("input"),a=p(),r=h("h3"),c=f("welcome to the docks"),l=p(),o=h("p"),i=f("This app is a ship builder for the game\n "),u=h("a"),$=f("Full Thrust"),E=f("\n ."),I=p(),k=h("p"),O=f("The app, beside any exception mentioned here, is trying to follow the\n "),D=h("a"),M=f("Cross Dimensions rules"),A=f("\n as closely as possible."),P=p(),T=h("p"),C=f("The app is mostly developed for Firefox. I also check as much as I can\n that I don't mess things too badly on Chrome. For the other browsers...\n caveat emptor."),S=p(),N=h("p"),j=f("Written by\n "),V=h("a"),q=f("Yanick Champoux"),L=f("\n . Code available on\n "),F=h("a"),B=f("Github"),this.h()},l(t){e=d(t,"ASIDE",{class:!0});var h=m(e);s=d(h,"DIV",{class:!0});var f=m(s);n=d(f,"INPUT",{type:!0,class:!0,value:!0}),f.forEach(v),a=y(h),r=d(h,"H3",{class:!0});var p=m(r);c=g(p,"welcome to the docks"),p.forEach(v),l=y(h),o=d(h,"P",{});var b=m(o);i=g(b,"This app is a ship builder for the game\n "),u=d(b,"A",{href:!0});var _=m(u);$=g(_,"Full Thrust"),_.forEach(v),E=g(b,"\n ."),b.forEach(v),I=y(h),k=d(h,"P",{});var w=m(k);O=g(w,"The app, beside any exception mentioned here, is trying to follow the\n "),D=d(w,"A",{href:!0});var x=m(D);M=g(x,"Cross Dimensions rules"),x.forEach(v),A=g(w,"\n as closely as possible."),w.forEach(v),P=y(h),T=d(h,"P",{});var U=m(T);C=g(U,"The app is mostly developed for Firefox. I also check as much as I can\n that I don't mess things too badly on Chrome. For the other browsers...\n caveat emptor."),U.forEach(v),S=y(h),N=d(h,"P",{});var z=m(N);j=g(z,"Written by\n "),V=d(z,"A",{href:!0});var H=m(V);q=g(H,"Yanick Champoux"),H.forEach(v),L=g(z,"\n . Code available on\n "),F=d(z,"A",{href:!0});var G=m(F);B=g(G,"Github"),G.forEach(v),z.forEach(v),h.forEach(v),this.h()},h(){b(n,"type","button"),b(n,"class","button small red"),n.value="close",b(s,"class","svelte-zox94u"),b(r,"class","svelte-zox94u"),b(u,"href","https://shop.groundzerogames.co.uk/rules.html"),b(D,"href","http://members.ozemail.com.au/~laranzu/fullthrust/rules/"),b(V,"href","https://twitter.com/yenzie"),b(F,"href","https://github.com/aotds/aotds-shipyard"),b(e,"class","svelte-zox94u")},m(h,f){_(h,e,f),w(e,s),w(s,n),w(e,a),w(e,r),w(r,c),w(e,l),w(e,o),w(o,i),w(o,u),w(u,$),w(o,E),w(e,I),w(e,k),w(k,O),w(k,D),w(D,M),w(k,A),w(e,P),w(e,T),w(T,C),w(e,S),w(e,N),w(N,j),w(N,V),w(V,q),w(N,L),w(N,F),w(F,B),z=!0,H||(G=pt(n,"click",t[0]),H=!0)},p:x,i(t){z||(et((()=>{U||(U=st(e,Mt,{x:-800,opacity:1},!0)),U.run(1)})),z=!0)},o(t){U||(U=st(e,Mt,{x:-800,opacity:1},!1)),U.run(0),z=!1},d(t){t&&v(e),t&&U&&U.end(),H=!1,G()}}}function $a(t){const e=at();return[()=>e("close")]}class ha extends i{constructor(t){super(),u(this,t,$a,ua,$,{})}}function fa(t){let e,s,n,a,r,c,l,o;const i=t[5].default,u=gt(i,t,t[4],null);return{c(){e=h("div"),u&&u.c(),s=p(),n=h("div"),a=f(t[0]),r=p(),c=h("div"),l=f(t[1]),this.h()},l(o){e=d(o,"DIV",{class:!0});var i=m(e);u&&u.l(i),i.forEach(v),s=y(o),n=d(o,"DIV",{class:!0});var $=m(n);a=g($,t[0]),$.forEach(v),r=y(o),c=d(o,"DIV",{class:!0});var h=m(c);l=g(h,t[1]),h.forEach(v),this.h()},h(){b(e,"class","svelte-cpog4c"),b(n,"class","mass svelte-cpog4c"),b(c,"class","cost svelte-cpog4c")},m(i,$){_(i,e,$),u&&u.m(e,null),_(i,s,$),_(i,n,$),w(n,a),t[6](n),_(i,r,$),_(i,c,$),w(c,l),t[7](c),o=!0},p(t,[e]){u&&u.p&&(!o||16&e)&&_t(u,i,t,t[4],e,null,null),(!o||1&e)&&tt(a,t[0]),(!o||2&e)&&tt(l,t[1])},i(t){o||(ot(u,t),o=!0)},o(t){it(u,t),o=!1},d(a){a&&v(e),u&&u.d(a),a&&v(s),a&&v(n),t[6](null),a&&v(r),a&&v(c),t[7](null)}}}function pa(t,e,s){let n,a,{$$slots:r={},$$scope:c}=e,{mass:l}=e,{cost:o}=e;const i=async t=>{t&&(t.classList.remove("updated"),t.offsetWidth,t.classList.add("updated"))};return t.$$set=t=>{"mass"in t&&s(0,l=t.mass),"cost"in t&&s(1,o=t.cost),"$$scope"in t&&s(4,c=t.$$scope)},t.$$.update=()=>{5&t.$$.dirty&&i(n),10&t.$$.dirty&&i(a)},[l,o,n,a,c,r,function(t){At[t?"unshift":"push"]((()=>{n=t,s(2,n)}))},function(t){At[t?"unshift":"push"]((()=>{a=t,s(3,a)}))}]}class da extends i{constructor(t){super(),u(this,t,pa,fa,$,{mass:0,cost:1})}}function ma(t){let e,s,n,a,r,c,l;const o=t[2].default,i=gt(o,t,t[1],null);return{c(){e=h("div"),s=h("h2"),n=f(t[0]),a=p(),r=h("hr"),c=p(),i&&i.c(),this.h()},l(l){e=d(l,"DIV",{class:!0});var o=m(e);s=d(o,"H2",{class:!0});var u=m(s);n=g(u,t[0]),u.forEach(v),a=y(o),r=d(o,"HR",{class:!0}),o.forEach(v),c=y(l),i&&i.l(l),this.h()},h(){b(s,"class","svelte-h4qygo"),b(r,"class","svelte-h4qygo"),b(e,"class","svelte-h4qygo")},m(t,o){_(t,e,o),w(e,s),w(s,n),w(e,a),w(e,r),_(t,c,o),i&&i.m(t,o),l=!0},p(t,[e]){(!l||1&e)&&tt(n,t[0]),i&&i.p&&(!l||2&e)&&_t(i,o,t,t[1],e,null,null)},i(t){l||(ot(i,t),l=!0)},o(t){it(i,t),l=!1},d(t){t&&v(e),t&&v(c),i&&i.d(t)}}}function ga(t,e,s){let{$$slots:n={},$$scope:a}=e,{label:r}=e;return t.$$set=t=>{"label"in t&&s(0,r=t.label),"$$scope"in t&&s(1,a=t.$$scope)},[r,a,n]}class va extends i{constructor(t){super(),u(this,t,ga,ma,$,{label:0})}}function ya(t){let e,s,n;return{c(){e=h("input"),this.h()},l(t){e=d(t,"INPUT",{type:!0,min:!0,class:!0}),this.h()},h(){b(e,"type","number"),b(e,"min","0"),b(e,"class","svelte-11x6jvv")},m(a,r){_(a,e,r),Tt(e,t[0]),s||(n=pt(e,"input",t[4]),s=!0)},p(t,s){1&s&&Pt(e.value)!==t[0]&&Tt(e,t[0])},d(t){t&&v(e),s=!1,n()}}}function ba(t){let e,s,n;return{c(){e=h("input"),this.h()},l(t){e=d(t,"INPUT",{type:!0,min:!0,class:!0}),this.h()},h(){b(e,"type","number"),b(e,"min","0"),b(e,"class","svelte-11x6jvv")},m(a,r){_(a,e,r),Tt(e,t[1]),s||(n=pt(e,"input",t[5]),s=!0)},p(t,s){2&s&&Pt(e.value)!==t[1]&&Tt(e,t[1])},d(t){t&&v(e),s=!1,n()}}}function _a(t){let e,s,n,a,r;return s=new Yn({props:{label:"screens",$$slots:{default:[ya]},$$scope:{ctx:t}}}),a=new Yn({props:{label:"advanced screens",$$slots:{default:[ba]},$$scope:{ctx:t}}}),{c(){e=h("div"),rt(s.$$.fragment),n=p(),rt(a.$$.fragment),this.h()},l(t){e=d(t,"DIV",{class:!0});var r=m(e);ct(s.$$.fragment,r),n=y(r),ct(a.$$.fragment,r),r.forEach(v),this.h()},h(){b(e,"class","svelte-11x6jvv")},m(t,c){_(t,e,c),lt(s,e,null),w(e,n),lt(a,e,null),r=!0},p(t,e){const n={};513&e&&(n.$$scope={dirty:e,ctx:t}),s.$set(n);const r={};514&e&&(r.$$scope={dirty:e,ctx:t}),a.$set(r)},i(t){r||(ot(s.$$.fragment,t),ot(a.$$.fragment,t),r=!0)},o(t){it(s.$$.fragment,t),it(a.$$.fragment,t),r=!1},d(t){t&&v(e),ut(s),ut(a)}}}function wa(t){let e,s;return e=new da({props:{cost:t[2],mass:t[3],$$slots:{default:[_a]},$$scope:{ctx:t}}}),{c(){rt(e.$$.fragment)},l(t){ct(e.$$.fragment,t)},m(t,n){lt(e,t,n),s=!0},p(t,[s]){const n={};4&s&&(n.cost=t[2]),8&s&&(n.mass=t[3]),515&s&&(n.$$scope={dirty:s,ctx:t}),e.$set(n)},i(t){s||(ot(e.$$.fragment,t),s=!0)},o(t){it(e.$$.fragment,t),s=!1},d(t){ut(e,t)}}}function xa(t,e,s){let{cost:n=0}=e,{mass:a=0}=e,{standard:r=0}=e,{advanced:c=0}=e;const l=at();return t.$$set=t=>{"cost"in t&&s(2,n=t.cost),"mass"in t&&s(3,a=t.mass),"standard"in t&&s(0,r=t.standard),"advanced"in t&&s(1,c=t.advanced)},t.$$.update=()=>{3&t.$$.dirty&&l("set_screens",{standard:r,advanced:c})},[r,c,n,a,function(){r=Pt(this.value),s(0,r)},function(){c=Pt(this.value),s(1,c)}]}class Ea extends i{constructor(t){super(),u(this,t,xa,wa,$,{cost:2,mass:3,standard:0,advanced:1})}}function Ia(t){let e,s,n;return{c(){e=h("input"),this.h()},l(t){e=d(t,"INPUT",{type:!0,min:!0,class:!0}),this.h()},h(){b(e,"type","number"),b(e,"min","0"),b(e,"class","svelte-qworsx")},m(a,r){_(a,e,r),Tt(e,t[0]),s||(n=pt(e,"input",t[2]),s=!0)},p(t,s){1&s&&Pt(e.value)!==t[0]&&Tt(e,t[0])},d(t){t&&v(e),s=!1,n()}}}function ka(t){let e,s;return e=new Yn({props:{label:`layer ${t[1]}`,$$slots:{default:[Ia]},$$scope:{ctx:t}}}),{c(){rt(e.$$.fragment)},l(t){ct(e.$$.fragment,t)},m(t,n){lt(e,t,n),s=!0},p(t,[s]){const n={};2&s&&(n.label=`layer ${t[1]}`),17&s&&(n.$$scope={dirty:s,ctx:t}),e.$set(n)},i(t){s||(ot(e.$$.fragment,t),s=!0)},o(t){it(e.$$.fragment,t),s=!1},d(t){ut(e,t)}}}function Oa(t,e,s){let{layer:n=1}=e,{rating:a=0}=e;const r=kt("ship");return t.$$set=t=>{"layer"in t&&s(1,n=t.layer),"rating"in t&&s(0,a=t.rating)},t.$$.update=()=>{3&t.$$.dirty&&(null==r||r.dispatch_action("set_armour_layer",{layer:n,rating:a}))},[a,n,function(){a=Pt(this.value),s(0,a)}]}class Da extends i{constructor(t){super(),u(this,t,Oa,ka,$,{layer:1,rating:0})}}function Ma(t,e,s){const n=t.slice();return n[7]=e[s],n}function Aa(t){let e,s,n;return{c(){e=h("input"),this.h()},l(t){e=d(t,"INPUT",{type:!0,min:!0,class:!0}),this.h()},h(){b(e,"type","number"),b(e,"min","0"),b(e,"class","svelte-1bx91qz")},m(a,r){_(a,e,r),Tt(e,t[3]),s||(n=pt(e,"input",t[4]),s=!0)},p(t,s){8&s&&Pt(e.value)!==t[3]&&Tt(e,t[3])},d(t){t&&v(e),s=!1,n()}}}function Pa(t,e){let s,n,a;const r=[e[7]];let c={};for(let l=0;lt[7].layer;for(let $=0;${"armour"in t&&s(2,n=t.armour),"cost"in t&&s(0,a=t.cost),"mass"in t&&s(1,r=t.mass)},t.$$.update=()=>{4&t.$$.dirty&&s(0,a=J.sum(J.map(n,"cost"))),4&t.$$.dirty&&s(1,r=J.sum(J.map(n,"mass"))),8&t.$$.dirty&&l("ship_change",ss.actions.set_armour_nbr_layers(c))},[a,r,n,c,function(){c=Pt(this.value),s(3,c)},function(e){dt(t,e)}]}class Na extends i{constructor(t){super(),u(this,t,Sa,Ca,$,{armour:2,cost:0,mass:1})}}function ja(t){let e,s,n;return{c(){e=h("input"),this.h()},l(t){e=d(t,"INPUT",{type:!0,min:!0,class:!0}),this.h()},h(){b(e,"type","number"),b(e,"min","0"),b(e,"class","svelte-1060pqd")},m(a,r){_(a,e,r),Tt(e,t[0]),s||(n=pt(e,"input",t[4]),s=!0)},p(t,s){1&s&&Pt(e.value)!==t[0]&&Tt(e,t[0])},d(t){t&&v(e),s=!1,n()}}}function Va(t){let e,s;return e=new Yn({props:{label:"cargo",$$slots:{default:[ja]},$$scope:{ctx:t}}}),{c(){rt(e.$$.fragment)},l(t){ct(e.$$.fragment,t)},m(t,n){lt(e,t,n),s=!0},p(t,s){const n={};33&s&&(n.$$scope={dirty:s,ctx:t}),e.$set(n)},i(t){s||(ot(e.$$.fragment,t),s=!0)},o(t){it(e.$$.fragment,t),s=!1},d(t){ut(e,t)}}}function qa(t){let e,s;return e=new da({props:{cost:t[1],mass:t[2],$$slots:{default:[Va]},$$scope:{ctx:t}}}),{c(){rt(e.$$.fragment)},l(t){ct(e.$$.fragment,t)},m(t,n){lt(e,t,n),s=!0},p(t,[s]){const n={};2&s&&(n.cost=t[1]),4&s&&(n.mass=t[2]),33&s&&(n.$$scope={dirty:s,ctx:t}),e.$set(n)},i(t){s||(ot(e.$$.fragment,t),s=!0)},o(t){it(e.$$.fragment,t),s=!1},d(t){ut(e,t)}}}function La(t,e,s){let{ship:n=kt("ship")}=e,{space:a=0}=e,{cost:r=0}=e,{mass:c=0}=e;return t.$$set=t=>{"ship"in t&&s(3,n=t.ship),"space"in t&&s(0,a=t.space),"cost"in t&&s(1,r=t.cost),"mass"in t&&s(2,c=t.mass)},t.$$.update=()=>{9&t.$$.dirty&&(null==n||n.dispatch_action("set_cargo",a))},[a,r,c,n,function(){a=Pt(this.value),s(0,a)}]}class Fa extends i{constructor(t){super(),u(this,t,La,qa,$,{ship:3,space:0,cost:1,mass:2})}}function Ba(t){let e,s,n,a,r,c,l,o,i,u,$,x,E,I;return{c(){e=h("div"),s=h("label"),n=h("input"),a=f("\n none"),r=p(),c=h("label"),l=h("input"),o=f("\n partial"),i=p(),u=h("label"),$=h("input"),x=f("\n full"),this.h()},l(t){e=d(t,"DIV",{class:!0});var h=m(e);s=d(h,"LABEL",{class:!0});var f=m(s);n=d(f,"INPUT",{type:!0,value:!0}),a=g(f,"\n none"),f.forEach(v),r=y(h),c=d(h,"LABEL",{class:!0});var p=m(c);l=d(p,"INPUT",{type:!0,value:!0}),o=g(p,"\n partial"),p.forEach(v),i=y(h),u=d(h,"LABEL",{class:!0});var b=m(u);$=d(b,"INPUT",{type:!0,value:!0}),x=g(b,"\n full"),b.forEach(v),h.forEach(v),this.h()},h(){b(n,"type","radio"),n.__value="none",n.value=n.__value,t[5][0].push(n),b(s,"class","svelte-6w28yb"),b(l,"type","radio"),l.__value="partial",l.value=l.__value,t[5][0].push(l),b(c,"class","svelte-6w28yb"),b($,"type","radio"),$.__value="full",$.value=$.__value,t[5][0].push($),b(u,"class","svelte-6w28yb"),b(e,"class","svelte-6w28yb")},m(h,f){_(h,e,f),w(e,s),w(s,n),n.checked=n.__value===t[0],w(s,a),w(e,r),w(e,c),w(c,l),l.checked=l.__value===t[0],w(c,o),w(e,i),w(e,u),w(u,$),$.checked=$.__value===t[0],w(u,x),E||(I=[pt(n,"change",t[4]),pt(l,"change",t[6]),pt($,"change",t[7])],E=!0)},p(t,e){1&e&&(n.checked=n.__value===t[0]),1&e&&(l.checked=l.__value===t[0]),1&e&&($.checked=$.__value===t[0])},d(s){s&&v(e),t[5][0].splice(t[5][0].indexOf(n),1),t[5][0].splice(t[5][0].indexOf(l),1),t[5][0].splice(t[5][0].indexOf($),1),E=!1,Ct(I)}}}function Ua(t){let e,s;return e=new Yn({props:{label:"streamlining",$$slots:{default:[Ba]},$$scope:{ctx:t}}}),{c(){rt(e.$$.fragment)},l(t){ct(e.$$.fragment,t)},m(t,n){lt(e,t,n),s=!0},p(t,s){const n={};257&s&&(n.$$scope={dirty:s,ctx:t}),e.$set(n)},i(t){s||(ot(e.$$.fragment,t),s=!0)},o(t){it(e.$$.fragment,t),s=!1},d(t){ut(e,t)}}}function za(t){let e,s;return e=new da({props:{cost:t[1],mass:t[2],$$slots:{default:[Ua]},$$scope:{ctx:t}}}),{c(){rt(e.$$.fragment)},l(t){ct(e.$$.fragment,t)},m(t,n){lt(e,t,n),s=!0},p(t,[s]){const n={};2&s&&(n.cost=t[1]),4&s&&(n.mass=t[2]),257&s&&(n.$$scope={dirty:s,ctx:t}),e.$set(n)},i(t){s||(ot(e.$$.fragment,t),s=!0)},o(t){it(e.$$.fragment,t),s=!1},d(t){ut(e,t)}}}function Ha(t,e,s){let{type:n="none"}=e,{cost:a=0}=e,{mass:r=0}=e,{ship:c=kt("ship")}=e;return t.$$set=t=>{"type"in t&&s(0,n=t.type),"cost"in t&&s(1,a=t.cost),"mass"in t&&s(2,r=t.mass),"ship"in t&&s(3,c=t.ship)},t.$$.update=()=>{9&t.$$.dirty&&(null==c||c.dispatch_action("set_streamlining",n))},[n,a,r,c,function(){n=this.__value,s(0,n)},[[]],function(){n=this.__value,s(0,n)},function(){n=this.__value,s(0,n)}]}class Ga extends i{constructor(t){super(),u(this,t,Ha,za,$,{type:0,cost:1,mass:2,ship:3})}}function Ra(t){let e,s,n;return{c(){e=h("input"),this.h()},l(t){e=d(t,"INPUT",{type:!0,min:!0,max:!0,class:!0}),this.h()},h(){b(e,"type","number"),b(e,"min",t[7]),b(e,"max",t[8]),b(e,"class","svelte-x10nn1")},m(a,r){_(a,e,r),Tt(e,t[0]),s||(n=pt(e,"input",t[10]),s=!0)},p(t,s){128&s&&b(e,"min",t[7]),256&s&&b(e,"max",t[8]),1&s&&Pt(e.value)!==t[0]&&Tt(e,t[0])},d(t){t&&v(e),s=!1,n()}}}function Wa(t){let e,s;return e=new Yn({props:{label:"integrity",$$slots:{default:[Ra]},$$scope:{ctx:t}}}),{c(){rt(e.$$.fragment)},l(t){ct(e.$$.fragment,t)},m(t,n){lt(e,t,n),s=!0},p(t,s){const n={};33153&s&&(n.$$scope={dirty:s,ctx:t}),e.$set(n)},i(t){s||(ot(e.$$.fragment,t),s=!0)},o(t){it(e.$$.fragment,t),s=!1},d(t){ut(e,t)}}}function Ya(t){let e,s,n,a,r,c,l,o,i,u;e=new da({props:{cost:t[1],mass:t[2],$$slots:{default:[Wa]},$$scope:{ctx:t}}});const $=[t[3]];let h={};for(let p=0;p<$.length;p+=1)h=It(h,$[p]);n=new Ea({props:h}),n.$on("set_screens",t[11]),r=new Na({props:{armour:t[4]}}),r.$on("ship_change",t[12]);const f=[t[5]];let d={};for(let p=0;p{"cost"in t&&s(1,r=t.cost),"mass"in t&&s(2,c=t.mass),"ship_mass"in t&&s(9,l=t.ship_mass),"rating"in t&&s(0,o=t.rating),"screens"in t&&s(3,i=t.screens),"armour"in t&&s(4,u=t.armour),"cargo"in t&&s(5,$=t.cargo),"streamlining"in t&&s(6,h=t.streamlining)},t.$$.update=()=>{512&t.$$.dirty&&s(7,n=Math.ceil(l/10)),512&t.$$.dirty&&s(8,a=l),1&t.$$.dirty&&f("change_hull",{rating:o})},[o,r,c,i,u,$,h,n,a,l,function(){o=Pt(this.value),s(0,o)},function(e){dt(t,e)},function(e){dt(t,e)},function(e){dt(t,e)}]}class Xa extends i{constructor(t){super(),u(this,t,Za,Ja,$,{cost:1,mass:2,ship_mass:9,rating:0,screens:3,armour:4,cargo:5,streamlining:6})}}function Ka(t){let e,s,n;return{c(){e=h("input"),this.h()},l(t){e=d(t,"INPUT",{type:!0,class:!0}),this.h()},h(){b(e,"type","number"),b(e,"class","short")},m(a,r){_(a,e,r),Tt(e,t[0]),s||(n=pt(e,"input",t[3]),s=!0)},p(t,s){1&s&&Pt(e.value)!==t[0]&&Tt(e,t[0])},d(t){t&&v(e),s=!1,n()}}}function Qa(t){let e,s;return e=new Yn({props:{label:"firecons",$$slots:{default:[Ka]},$$scope:{ctx:t}}}),{c(){rt(e.$$.fragment)},l(t){ct(e.$$.fragment,t)},m(t,n){lt(e,t,n),s=!0},p(t,s){const n={};33&s&&(n.$$scope={dirty:s,ctx:t}),e.$set(n)},i(t){s||(ot(e.$$.fragment,t),s=!0)},o(t){it(e.$$.fragment,t),s=!1},d(t){ut(e,t)}}}function tr(t){let e,s;return e=new da({props:{cost:t[1],mass:t[2],$$slots:{default:[Qa]},$$scope:{ctx:t}}}),{c(){rt(e.$$.fragment)},l(t){ct(e.$$.fragment,t)},m(t,n){lt(e,t,n),s=!0},p(t,[s]){const n={};2&s&&(n.cost=t[1]),4&s&&(n.mass=t[2]),33&s&&(n.$$scope={dirty:s,ctx:t}),e.$set(n)},i(t){s||(ot(e.$$.fragment,t),s=!0)},o(t){it(e.$$.fragment,t),s=!1},d(t){ut(e,t)}}}function er(t,e,s){let{nbr:n}=e,{cost:a}=e,{mass:r=0}=e;const c=at();return t.$$set=t=>{"nbr"in t&&s(0,n=t.nbr),"cost"in t&&s(1,a=t.cost),"mass"in t&&s(2,r=t.mass)},t.$$.update=()=>{1&t.$$.dirty&&c("change_firecons",n)},[n,a,r,function(){n=Pt(this.value),s(0,n)}]}class sr extends i{constructor(t){super(),u(this,t,er,tr,$,{nbr:0,cost:1,mass:2})}}function nr(t,e,s){const n=t.slice();return n[8]=e[s],n}function ar(t,e){let s,n,a,r,c,l,o,i=e[8]+"";return{key:t,first:null,c(){s=h("label"),n=h("input"),a=p(),r=f(i),c=p(),this.h()},l(t){s=d(t,"LABEL",{class:!0});var e=m(s);n=d(e,"INPUT",{type:!0,value:!0}),a=y(e),r=g(e,i),c=y(e),e.forEach(v),this.h()},h(){b(n,"type","radio"),n.__value=e[8],n.value=n.__value,e[6][0].push(n),b(s,"class","svelte-1ozsoxu"),this.first=s},m(t,i){_(t,s,i),w(s,n),n.checked=n.__value===e[0],w(s,a),w(s,r),w(s,c),l||(o=[pt(n,"change",e[5]),pt(n,"change",e[3])],l=!0)},p(t,s){e=t,1&s&&(n.checked=n.__value===e[0])},d(t){t&&v(s),e[6][0].splice(e[6][0].indexOf(n),1),l=!1,Ct(o)}}}function rr(t){let e,s=[],n=new Map,a=t[4];const r=t=>t[8];for(let c=0;c{"type"in t&&s(0,n=t.type),"cost"in t&&s(1,a=t.cost),"mass"in t&&s(2,r=t.mass)},[n,a,r,()=>c("change_ftl",n),["none","standard","advanced"],function(){n=this.__value,s(0,n)},[[]]]}class ir extends i{constructor(t){super(),u(this,t,or,lr,$,{type:0,cost:1,mass:2})}}function ur(t){let e,s,n;return{c(){e=h("input"),this.h()},l(t){e=d(t,"INPUT",{type:!0,min:!0,max:!0,step:!0,class:!0}),this.h()},h(){b(e,"type","number"),b(e,"min","0"),b(e,"max","20"),b(e,"step","1"),b(e,"class","svelte-3grq2v")},m(a,r){_(a,e,r),Tt(e,t[1]),s||(n=pt(e,"input",t[4]),s=!0)},p(t,s){2&s&&Pt(e.value)!==t[1]&&Tt(e,t[1])},d(t){t&&v(e),s=!1,n()}}}function $r(t){let e,s,n,a,r,c,l,o,i;return s=new Yn({props:{label:"thrust rating",$$slots:{default:[ur]},$$scope:{ctx:t}}}),{c(){e=h("div"),rt(s.$$.fragment),n=p(),a=h("label"),r=h("input"),c=f(" advanced"),this.h()},l(t){e=d(t,"DIV",{class:!0});var l=m(e);ct(s.$$.fragment,l),n=y(l),a=d(l,"LABEL",{class:!0});var o=m(a);r=d(o,"INPUT",{type:!0}),c=g(o," advanced"),o.forEach(v),l.forEach(v),this.h()},h(){b(r,"type","checkbox"),b(a,"class","svelte-3grq2v"),b(e,"class","svelte-3grq2v")},m(u,$){_(u,e,$),lt(s,e,null),w(e,n),w(e,a),w(a,r),r.checked=t[0],w(a,c),l=!0,o||(i=pt(r,"change",t[5]),o=!0)},p(t,e){const n={};130&e&&(n.$$scope={dirty:e,ctx:t}),s.$set(n),1&e&&(r.checked=t[0])},i(t){l||(ot(s.$$.fragment,t),l=!0)},o(t){it(s.$$.fragment,t),l=!1},d(t){t&&v(e),ut(s),o=!1,i()}}}function hr(t){let e,s;return e=new da({props:{cost:t[2],mass:t[3],$$slots:{default:[$r]},$$scope:{ctx:t}}}),{c(){rt(e.$$.fragment)},l(t){ct(e.$$.fragment,t)},m(t,n){lt(e,t,n),s=!0},p(t,[s]){const n={};4&s&&(n.cost=t[2]),8&s&&(n.mass=t[3]),131&s&&(n.$$scope={dirty:s,ctx:t}),e.$set(n)},i(t){s||(ot(e.$$.fragment,t),s=!0)},o(t){it(e.$$.fragment,t),s=!1},d(t){ut(e,t)}}}function fr(t,e,s){let{cost:n}=e,{mass:a}=e,{advanced:r=!1}=e,{rating:c=0}=e;const l=at();return console.log(r),t.$$set=t=>{"cost"in t&&s(2,n=t.cost),"mass"in t&&s(3,a=t.mass),"advanced"in t&&s(0,r=t.advanced),"rating"in t&&s(1,c=t.rating)},t.$$.update=()=>{3&t.$$.dirty&&l("change_engine",{rating:c,advanced:r})},[r,c,n,a,function(){c=Pt(this.value),s(1,c)},function(){r=this.checked,s(0,r)}]}class pr extends i{constructor(t){super(),u(this,t,fr,hr,$,{cost:2,mass:3,advanced:0,rating:1})}}function dr(t){let e,s,n,a;const r=[t[1]];let c={};for(let i=0;i{"ftl"in t&&s(0,n=t.ftl),"engine"in t&&s(1,a=t.engine)},[n,a,function(e){dt(t,e)},function(e){dt(t,e)}]}class vr extends i{constructor(t){super(),u(this,t,gr,mr,$,{ftl:0,engine:1})}}function yr(t,e,s){const n=t.slice();return n[2]=e[s],n}function br(t){let e,s,n,a,r,c,l,o,i,u,$;return{c(){e=h("select"),s=h("option"),n=f("1"),a=h("option"),r=f("2"),c=h("option"),l=f("3"),o=h("option"),i=f("4"),this.h()},l(t){e=d(t,"SELECT",{});var u=m(e);s=d(u,"OPTION",{value:!0});var $=m(s);n=g($,"1"),$.forEach(v),a=d(u,"OPTION",{value:!0});var h=m(a);r=g(h,"2"),h.forEach(v),c=d(u,"OPTION",{value:!0});var f=m(c);l=g(f,"3"),f.forEach(v),o=d(u,"OPTION",{value:!0});var p=m(o);i=g(p,"4"),p.forEach(v),u.forEach(v),this.h()},h(){s.__value="1",s.value=s.__value,a.__value="2",a.value=a.__value,c.__value="3",c.value=c.__value,o.__value="4",o.value=o.__value,void 0===t[0]&&et((()=>t[8].call(e)))},m(h,f){_(h,e,f),w(e,s),w(s,n),w(e,a),w(a,r),w(e,c),w(c,l),w(e,o),w(o,i),Dt(e,t[0]),u||($=pt(e,"change",t[8]),u=!0)},p(t,s){1&s&&Dt(e,t[0])},d(t){t&&v(e),u=!1,$()}}}function _r(t,e){let s,n,a,r=e[2]+"";return{key:t,first:null,c(){s=h("option"),n=f(r),this.h()},l(t){s=d(t,"OPTION",{value:!0});var e=m(s);n=g(e,r),e.forEach(v),this.h()},h(){s.__value=a=e[2],s.value=s.__value,this.first=s},m(t,e){_(t,s,e),w(s,n)},p(t,c){e=t,1&c&&r!==(r=e[2]+"")&&tt(n,r),1&c&&a!==(a=e[2])&&(s.__value=a,s.value=s.__value)},d(t){t&&v(s)}}}function wr(t){let e,s,n,a=[],r=new Map,c=t[3][t[0]]||[];const l=t=>t[2];for(let o=0;ot[9].call(e)))},m(r,c){_(r,e,c);for(let t=0;t{if("broadside"===o)return;let e=n.findIndex((e=>e===t));const a=[];J.range(o).forEach((t=>{a.push(n[e]),e=(e+1)%n.length})),s(1,r=a)};let u=1,$="";const h=at();return t.$$set=t=>{"weapon_class"in t&&s(0,a=t.weapon_class),"arcs"in t&&s(1,r=t.arcs),"id"in t&&s(5,c=t.id)},t.$$.update=()=>{if(1&t.$$.dirty&&s(2,o=l[a][0]),6&t.$$.dirty&&r.length!==o)if("broadside"===o)s(1,r=n.filter((t=>1===t.length)));else{let t=n.findIndex((t=>r[0]));-1===t&&(t=0);const e=[];J.range(o).forEach((s=>{e.push(n[t]),t=(t+1)%n.length})),s(1,r=e)}6&t.$$.dirty&&console.log({arcs:r,nbr_arcs:o}),1&t.$$.dirty&&a&&s(6,u=1),2&t.$$.dirty&&s(7,$=r.join(":")),129&t.$$.dirty&&h("change",{weapon_class:a,arcs:$.split(":")})},[a,r,o,l,i,c,u,$,function(){a=St(this),s(0,a)},function(){o=St(this),s(2,o),s(3,l),s(0,a),s(3,l),s(0,a)},({detail:t})=>i(t)]}class Ir extends i{constructor(t){super(),u(this,t,Er,xr,$,{weapon_class:0,arcs:1,id:5})}}function kr(t){let e,s,n,a,r;return a=new gn({props:{selected:t[0]}}),a.$on("click_arc",t[4]),{c(){e=h("label"),s=f("submunition pack"),n=p(),rt(a.$$.fragment)},l(t){e=d(t,"LABEL",{});var r=m(e);s=g(r,"submunition pack"),r.forEach(v),n=y(t),ct(a.$$.fragment,t)},m(t,c){_(t,e,c),w(e,s),_(t,n,c),lt(a,t,c),r=!0},p(t,[e]){const s={};1&e&&(s.selected=t[0]),a.$set(s)},i(t){r||(ot(a.$$.fragment,t),r=!0)},o(t){it(a.$$.fragment,t),r=!1},d(t){t&&v(e),t&&v(n),ut(a,t)}}}function Or(t,e,s){let{arcs:n=["F"]}=e,{ship_change:a=kt("ship_change")||(()=>{})}=e;const r=t=>{n[0]!==t&&s(0,n=[t])},c=at();let l;return t.$$set=t=>{"arcs"in t&&s(0,n=t.arcs),"ship_change"in t&&s(2,a=t.ship_change)},t.$$.update=()=>{1&t.$$.dirty&&s(3,l=n.join(":")),8&t.$$.dirty&&c("change",{arcs:l.split(":")})},[n,r,a,l,({detail:t})=>r(t)]}class Dr extends i{constructor(t){super(),u(this,t,Or,kr,$,{arcs:0,ship_change:2})}}function Mr(t){let e,s;return{c(){e=h("label"),s=f("point defence system")},l(t){e=d(t,"LABEL",{});var n=m(e);s=g(n,"point defence system"),n.forEach(v)},m(t,n){_(t,e,n),w(e,s)},p:x,i:x,o:x,d(t){t&&v(e)}}}class Ar extends i{constructor(t){super(),u(this,t,null,Mr,$,{})}}function Pr(t){let e,s;return{c(){e=h("label"),s=f("scattergun")},l(t){e=d(t,"LABEL",{});var n=m(e);s=g(n,"scattergun"),n.forEach(v)},m(t,n){_(t,e,n),w(e,s)},p:x,i:x,o:x,d(t){t&&v(e)}}}class Tr extends i{constructor(t){super(),u(this,t,null,Pr,$,{})}}function Cr(t){let e,s,n,a,r;return a=new gn({props:{selected:t[0]}}),a.$on("click_arc",t[4]),{c(){e=h("label"),s=f("needle weapon"),n=p(),rt(a.$$.fragment)},l(t){e=d(t,"LABEL",{});var r=m(e);s=g(r,"needle weapon"),r.forEach(v),n=y(t),ct(a.$$.fragment,t)},m(t,c){_(t,e,c),w(e,s),_(t,n,c),lt(a,t,c),r=!0},p(t,[e]){const s={};1&e&&(s.selected=t[0]),a.$set(s)},i(t){r||(ot(a.$$.fragment,t),r=!0)},o(t){it(a.$$.fragment,t),r=!1},d(t){t&&v(e),t&&v(n),ut(a,t)}}}function Sr(t,e,s){let{arcs:n=["F"]}=e,{ship_change:a=kt("ship_change")||(()=>{})}=e;const r=t=>{n[0]!==t&&s(0,n=[t])},c=at();let l;return t.$$set=t=>{"arcs"in t&&s(0,n=t.arcs),"ship_change"in t&&s(2,a=t.ship_change)},t.$$.update=()=>{1&t.$$.dirty&&s(3,l=n.join(":")),8&t.$$.dirty&&c("change",{arcs:l.split(":")})},[n,r,a,l,({detail:t})=>r(t)]}class Nr extends i{constructor(t){super(),u(this,t,Sr,Cr,$,{arcs:0,ship_change:2})}}function jr(t){let e,s,n,a,r,c,l;const o=[t[0]];var i=t[3][t[4]];function u(t){let e={};for(let s=0;s{ut(t,1)})),bt()}i?(a=new i(u()),a.$on("change",t[6]),rt(a.$$.fragment),ot(a.$$.fragment,1),lt(a,e,null)):a=null}else i&&a.$set(n)},i(t){r||(a&&ot(a.$$.fragment,t),r=!0)},o(t){a&&it(a.$$.fragment,t),r=!1},d(t){t&&v(e),a&&ut(a),c=!1,l()}}}function Vr(t){let e,s;return e=new da({props:{cost:t[1],mass:t[2],$$slots:{default:[jr]},$$scope:{ctx:t}}}),{c(){rt(e.$$.fragment)},l(t){ct(e.$$.fragment,t)},m(t,n){lt(e,t,n),s=!0},p(t,[s]){const n={};2&s&&(n.cost=t[1]),4&s&&(n.mass=t[2]),513&s&&(n.$$scope={dirty:s,ctx:t}),e.$set(n)},i(t){s||(ot(e.$$.fragment,t),s=!0)},o(t){it(e.$$.fragment,t),s=!1},d(t){ut(e,t)}}}function qr(t,e,s){const n={beam:Ir,submunition:Dr,pds:Ar,scattergun:Tr,needle:Nr};let{weapon:a={}}=e,{id:r}=e,{cost:c}=e,{mass:o}=e,{ship:i=kt("ship")}=e,u=a.weapon_type;return t.$$set=t=>{"weapon"in t&&s(0,a=t.weapon),"id"in t&&s(7,r=t.id),"cost"in t&&s(1,c=t.cost),"mass"in t&&s(2,o=t.mass),"ship"in t&&s(8,i=t.ship)},[a,c,o,n,u,()=>null==i?void 0:i.dispatch_action("remove_weapon",r),({detail:t})=>{null==i||i.dispatch_action("set_weapon",l({id:r,weapon_type:u},t))},r,i]}class Lr extends i{constructor(t){super(),u(this,t,qr,Vr,$,{weapon:0,id:7,cost:1,mass:2,ship:8})}}function Fr(t,e,s){const n=t.slice();return n[0]=e[s],n}function Br(t,e){let s,n,a=e[0]+"";return{key:t,first:null,c(){s=h("option"),n=f(a),this.h()},l(t){s=d(t,"OPTION",{value:!0});var e=m(s);n=g(e,a),e.forEach(v),this.h()},h(){s.__value=e[0],s.value=s.__value,this.first=s},m(t,e){_(t,s,e),w(s,n)},p(t,s){e=t},d(t){t&&v(s)}}}function Ur(t){let e,s,n,a=[],r=new Map,c=t[4];const l=t=>t[0];for(let o=0;ot[7].call(e)))},m(r,c){_(r,e,c);for(let t=0;tt));let{id:a=1}=e,{type:r="standard"}=e,{ftl:c=!1}=e,{cost:l=0}=e,{mass:o=0}=e,{ship:i=kt("ship")}=e;return t.$$set=t=>{"id"in t&&s(1,a=t.id),"type"in t&&s(0,r=t.type),"ftl"in t&&s(5,c=t.ftl),"cost"in t&&s(2,l=t.cost),"mass"in t&&s(3,o=t.mass),"ship"in t&&s(6,i=t.ship)},t.$$.update=()=>{67&t.$$.dirty&&(null==i||i.dispatch_action("set_squadron",{id:a,type:r}))},[r,a,l,o,n,c,i,function(){r=St(this),s(0,r),s(4,n)}]}class Rr extends i{constructor(t){super(),u(this,t,Gr,Hr,$,{id:1,type:0,ftl:5,cost:2,mass:3,ship:6})}}function Wr(t,e,s){const n=t.slice();return n[6]=e[s],n}function Yr(t){let e,s,n;return{c(){e=h("input"),this.h()},l(t){e=d(t,"INPUT",{type:!0,min:!0}),this.h()},h(){b(e,"type","number"),b(e,"min","0")},m(a,r){_(a,e,r),Tt(e,t[0]),s||(n=pt(e,"input",t[5]),s=!0)},p(t,s){1&s&&Pt(e.value)!==t[0]&&Tt(e,t[0])},d(t){t&&v(e),s=!1,n()}}}function Jr(t){let e,s;return e=new Yn({props:{label:"bays",$$slots:{default:[Yr]},$$scope:{ctx:t}}}),{c(){rt(e.$$.fragment)},l(t){ct(e.$$.fragment,t)},m(t,n){lt(e,t,n),s=!0},p(t,s){const n={};513&s&&(n.$$scope={dirty:s,ctx:t}),e.$set(n)},i(t){s||(ot(e.$$.fragment,t),s=!0)},o(t){it(e.$$.fragment,t),s=!1},d(t){ut(e,t)}}}function Zr(t,e){let s,n,a;const r=[e[6]];let c={};for(let l=0;lt[6].id;for(let i=0;i{"bays"in t&&s(0,n=t.bays),"squadrons"in t&&s(1,a=t.squadrons),"cost"in t&&s(2,r=t.cost),"mass"in t&&s(3,c=t.mass),"ship"in t&&s(4,l=t.ship)},t.$$.update=()=>{17&t.$$.dirty&&(null==l||l.dispatch_action("set_carrier_bays",n))},[n,a,r,c,l,function(){n=Pt(this.value),s(0,n)}]}class tc extends i{constructor(t){super(),u(this,t,Qr,Kr,$,{bays:0,squadrons:1,cost:2,mass:3,ship:4})}}function ec(t){let e,s,n;return{c(){e=h("input"),this.h()},l(t){e=d(t,"INPUT",{type:!0,class:!0}),this.h()},h(){b(e,"type","number"),b(e,"class","short")},m(a,r){_(a,e,r),Tt(e,t[0]),s||(n=pt(e,"input",t[4]),s=!0)},p(t,s){1&s&&Pt(e.value)!==t[0]&&Tt(e,t[0])},d(t){t&&v(e),s=!1,n()}}}function sc(t){let e,s;return e=new Yn({props:{label:"ADFC",$$slots:{default:[ec]},$$scope:{ctx:t}}}),{c(){rt(e.$$.fragment)},l(t){ct(e.$$.fragment,t)},m(t,n){lt(e,t,n),s=!0},p(t,s){const n={};33&s&&(n.$$scope={dirty:s,ctx:t}),e.$set(n)},i(t){s||(ot(e.$$.fragment,t),s=!0)},o(t){it(e.$$.fragment,t),s=!1},d(t){ut(e,t)}}}function nc(t){let e,s;return e=new da({props:{cost:t[1],mass:t[2],$$slots:{default:[sc]},$$scope:{ctx:t}}}),{c(){rt(e.$$.fragment)},l(t){ct(e.$$.fragment,t)},m(t,n){lt(e,t,n),s=!0},p(t,[s]){const n={};2&s&&(n.cost=t[1]),4&s&&(n.mass=t[2]),33&s&&(n.$$scope={dirty:s,ctx:t}),e.$set(n)},i(t){s||(ot(e.$$.fragment,t),s=!0)},o(t){it(e.$$.fragment,t),s=!1},d(t){ut(e,t)}}}function ac(t,e,s){let{rating:n=0}=e,{cost:a=0}=e,{mass:r=0}=e,{ship:c=kt("ship")}=e;return t.$$set=t=>{"rating"in t&&s(0,n=t.rating),"cost"in t&&s(1,a=t.cost),"mass"in t&&s(2,r=t.mass),"ship"in t&&s(3,c=t.ship)},t.$$.update=()=>{9&t.$$.dirty&&(null==c||c.dispatch_action("set_adfc",n))},[n,a,r,c,function(){n=Pt(this.value),s(0,n)}]}class rc extends i{constructor(t){super(),u(this,t,ac,nc,$,{rating:0,cost:1,mass:2,ship:3})}}function cc(t){let e,s,n,a,r,c,l,o,i,u,$,x,E,I,k;return{c(){e=h("select"),s=h("option"),n=f("beam"),a=h("option"),r=f("submunition pack"),c=h("option"),l=f("point defence system"),o=h("option"),i=f("scattergun"),u=h("option"),$=f("needle weapon"),x=p(),E=h("input"),this.h()},l(t){e=d(t,"SELECT",{});var h=m(e);s=d(h,"OPTION",{value:!0});var f=m(s);n=g(f,"beam"),f.forEach(v),a=d(h,"OPTION",{value:!0});var p=m(a);r=g(p,"submunition pack"),p.forEach(v),c=d(h,"OPTION",{value:!0});var b=m(c);l=g(b,"point defence system"),b.forEach(v),o=d(h,"OPTION",{value:!0});var _=m(o);i=g(_,"scattergun"),_.forEach(v),u=d(h,"OPTION",{value:!0});var w=m(u);$=g(w,"needle weapon"),w.forEach(v),h.forEach(v),x=y(t),E=d(t,"INPUT",{type:!0,value:!0,class:!0}),this.h()},h(){s.__value="beam",s.value=s.__value,a.__value="submunition",a.value=a.__value,c.__value="pds",c.value=c.__value,o.__value="scattergun",o.value=o.__value,u.__value="needle",u.value=u.__value,void 0===t[0]&&et((()=>t[3].call(e))),b(E,"type","button"),E.value="add weapon",b(E,"class","button small blue")},m(h,f){_(h,e,f),w(e,s),w(s,n),w(e,a),w(a,r),w(e,c),w(c,l),w(e,o),w(o,i),w(e,u),w(u,$),Dt(e,t[0]),_(h,x,f),_(h,E,f),I||(k=[pt(e,"change",t[3]),pt(E,"click",t[1])],I=!0)},p(t,s){1&s&&Dt(e,t[0])},d(t){t&&v(e),t&&v(x),t&&v(E),I=!1,Ct(k)}}}function lc(t){let e,s;return e=new Yn({props:{label:"weapon type",$$slots:{default:[cc]},$$scope:{ctx:t}}}),{c(){rt(e.$$.fragment)},l(t){ct(e.$$.fragment,t)},m(t,n){lt(e,t,n),s=!0},p(t,[s]){const n={};17&s&&(n.$$scope={dirty:s,ctx:t}),e.$set(n)},i(t){s||(ot(e.$$.fragment,t),s=!0)},o(t){it(e.$$.fragment,t),s=!1},d(t){ut(e,t)}}}function oc(t,e,s){let{weapon_type:n="beam"}=e,{ship:a=kt("ship")}=e;return t.$$set=t=>{"weapon_type"in t&&s(0,n=t.weapon_type),"ship"in t&&s(2,a=t.ship)},[n,()=>null==a?void 0:a.dispatch_action("add_weapon",n),a,function(){n=St(this),s(0,n)}]}class ic extends i{constructor(t){super(),u(this,t,oc,lc,$,{weapon_type:0,ship:2})}}function uc(t,e,s){const n=t.slice();return n[23]=e[s],n}function $c(t){let e,s;return e=new ha({props:{show:t[2]}}),e.$on("close",t[12]),{c(){rt(e.$$.fragment)},l(t){ct(e.$$.fragment,t)},m(t,n){lt(e,t,n),s=!0},p(t,s){const n={};4&s&&(n.show=t[2]),e.$set(n)},i(t){s||(ot(e.$$.fragment,t),s=!0)},o(t){it(e.$$.fragment,t),s=!1},d(t){ut(e,t)}}}function hc(t){let e,s,n,a,r,c,l,o,i,u,$,x,E,I,k,O,D,M,A;s=new ia({}),a=new vr({props:{ftl:t[1].ftl,engine:t[1].engine}}),a.$on("change_ftl",t[5]),a.$on("change_engine",t[6]);const P=[{ship_mass:t[1].general.mass},t[1].structure.hull,{screens:t[1].structure.screens},{armour:t[1].structure.armour},{cargo:t[1].cargo},{streamlining:t[1].streamlining}];let T={};for(let h=0;ht[23].id;for(let p=0;p{G=null})),bt());let s=L;L=Y(t),L===s?W[L].p(t,e):(vt(),it(W[s],1,1,(()=>{W[s]=null})),bt(),F=W[L],F?F.p(t,e):(F=W[L]=R[L](t),F.c()),ot(F,1),F.m(B.parentNode,B))},i(t){U||(ot(e.$$.fragment,t),ot(n.$$.fragment,t),ot(G),ot(F),U=!0)},o(t){it(e.$$.fragment,t),it(n.$$.fragment,t),it(G),it(F),U=!1},d(t){ut(e,t),t&&v(s),ut(n,t),t&&v(a),t&&v(r),t&&v(V),G&&G.d(t),t&&v(q),W[L].d(t),t&&v(B),z=!1,Ct(H)}}}function vc(t,e,s){let n;const a=(()=>{let t;t=window.localStorage.getItem("aotds-shipyard"),t=t?JSON.parse(t):void 0;const e=Is.createStore(t,(t=>ks(X(t))));let s;return e.dispatch(e.actions.set_ship_reqs(Gt(e.getState()))),Object.entries(e.actions).forEach((([t,s])=>{e.dispatch[t]=t=>e.dispatch(s(t))})),e.subscribe((()=>{let t=e.getState();s!==t&&(s=t,window.localStorage.setItem("aotds-shipyard",JSON.stringify(t)))})),{subscribe:K(e.getState(),(t=>e.subscribe((()=>{t(e.getState())})))).subscribe,dispatch:e.dispatch,actions:e.actions,selectors:e.selectors,dispatch_action:(t,s)=>e.dispatch[t](s)}})();Nt(t,a,(t=>s(1,n=t))),jt("ship",a),n.general.name;let r=[];const c=a.dispatch.reset;let l=!1;let o=null;const i=t=>s(3,o=t);return t.$$.update=()=>{2&t.$$.dirty&&s(0,r=n.weaponry.weapons),1&t.$$.dirty&&console.log(r)},[r,n,l,o,a,({detail:t})=>a.dispatch.set_ftl(t),({detail:t})=>a.dispatch.set_engine(t),({detail:t})=>a.dispatch.set_hull(t),({detail:t})=>a.dispatch.set_firecons(t),c,({detail:t})=>a.dispatch.set_screens(t),({detail:t})=>a.dispatch(t),()=>s(2,l=!l),i,()=>i(null),()=>i("json"),()=>i("print"),()=>i(null)]}class yc extends i{constructor(t){super(),u(this,t,vc,gc,$,{})}}function bc(t,e,s){const n=t.slice();return n[1]=e[s],n}function _c(t,e){let s;return{key:t,first:null,c(){s=h("link"),this.h()},l(t){s=d(t,"LINK",{rel:!0,href:!0}),this.h()},h(){b(s,"rel","stylesheet"),b(s,"href",e[1]),this.first=s},m(t,e){_(t,s,e)},p(t,s){e=t},d(t){t&&v(s)}}}function wc(t){let e,s,n,a,r=[],c=new Map;e=new yc({});let l=t[0];const o=t=>t[1];for(let i=0;iqt+t))]}export default class extends i{constructor(t){super(),u(this,t,xc,wc,$,{})}} diff --git a/docs/_app/start-b075574c.js b/docs/_app/start-b075574c.js new file mode 100644 index 0000000..5afae9a --- /dev/null +++ b/docs/_app/start-b075574c.js @@ -0,0 +1 @@ +var t=Object.defineProperty,e=Object.defineProperties,r=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,a=(e,r,s)=>r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[r]=s,i=(t,e)=>{for(var r in e||(e={}))n.call(e,r)&&a(t,r,e[r]);if(s)for(var r of s(e))o.call(e,r)&&a(t,r,e[r]);return t};import{S as l,i as c,s as u,e as h,c as d,a as p,d as f,b as g,f as m,t as y,g as _,h as v,j as b,k as $,l as w,m as x,n as E,o as q,p as R,q as S,r as L,u as k,v as O,w as U,x as j,y as P,z as A,A as T,B as N,C}from"./chunks/vendor-d7482fce.js";import{s as I}from"./chunks/paths-45dac81d.js";function D(t){let e,r,s;const n=[t[2]||{}];var o=t[0][1];function a(t){let e={$$slots:{default:[B]},$$scope:{ctx:t}};for(let r=0;r{U(t,1)})),k()}o?(e=new o(a(t)),b(e.$$.fragment),O(e.$$.fragment,1),q(e,r.parentNode,r)):e=null}else o&&e.$set(i)},i(t){s||(e&&O(e.$$.fragment,t),s=!0)},o(t){e&&L(e.$$.fragment,t),s=!1},d(t){t&&f(r),e&&U(e,t)}}}function V(t){let e,r,s;const n=[t[3]||{}];var o=t[0][2];function a(t){let e={};for(let r=0;r{U(t,1)})),k()}o?(e=new o(a()),b(e.$$.fragment),O(e.$$.fragment,1),q(e,r.parentNode,r)):e=null}else o&&e.$set(i)},i(t){s||(e&&O(e.$$.fragment,t),s=!0)},o(t){e&&L(e.$$.fragment,t),s=!1},d(t){t&&f(r),e&&U(e,t)}}}function B(t){let e,r,s=t[0][2]&&V(t);return{c(){s&&s.c(),e=w()},l(t){s&&s.l(t),e=w()},m(t,n){s&&s.m(t,n),m(t,e,n),r=!0},p(t,r){t[0][2]?s?(s.p(t,r),1&r&&O(s,1)):(s=V(t),s.c(),O(s,1),s.m(e.parentNode,e)):s&&(N(),L(s,1,1,(()=>{s=null})),k())},i(t){r||(O(s),r=!0)},o(t){L(s),r=!1},d(t){s&&s.d(t),t&&f(e)}}}function K(t){let e,r,s=t[0][1]&&D(t);return{c(){s&&s.c(),e=w()},l(t){s&&s.l(t),e=w()},m(t,n){s&&s.m(t,n),m(t,e,n),r=!0},p(t,r){t[0][1]?s?(s.p(t,r),1&r&&O(s,1)):(s=D(t),s.c(),O(s,1),s.m(e.parentNode,e)):s&&(N(),L(s,1,1,(()=>{s=null})),k())},i(t){r||(O(s),r=!0)},o(t){L(s),r=!1},d(t){s&&s.d(t),t&&f(e)}}}function W(t){let e,r=t[5]&&z(t);return{c(){e=h("div"),r&&r.c(),this.h()},l(t){e=d(t,"DIV",{id:!0,"aria-live":!0,"aria-atomic":!0,class:!0});var s=p(e);r&&r.l(s),s.forEach(f),this.h()},h(){g(e,"id","svelte-announcer"),g(e,"aria-live","assertive"),g(e,"aria-atomic","true"),g(e,"class","svelte-1j55zn5")},m(t,s){m(t,e,s),r&&r.m(e,null)},p(t,s){t[5]?r?r.p(t,s):(r=z(t),r.c(),r.m(e,null)):r&&(r.d(1),r=null)},d(t){t&&f(e),r&&r.d()}}}function z(t){let e;return{c(){e=y(t[6])},l(r){e=_(r,t[6])},m(t,r){m(t,e,r)},p(t,r){64&r&&v(e,t[6])},d(t){t&&f(e)}}}function M(t){let e,r,s,n;const o=[t[1]||{}];var a=t[0][0];function i(t){let e={$$slots:{default:[K]},$$scope:{ctx:t}};for(let r=0;r{U(t,1)})),k()}a?(e=new a(i(t)),b(e.$$.fragment),O(e.$$.fragment,1),q(e,r.parentNode,r)):e=null}else a&&e.$set(c);t[4]?l?l.p(t,n):(l=W(t),l.c(),l.m(s.parentNode,s)):l&&(l.d(1),l=null)},i(t){n||(e&&O(e.$$.fragment,t),n=!0)},o(t){e&&L(e.$$.fragment,t),n=!1},d(t){e&&U(e,t),t&&f(r),l&&l.d(t),t&&f(s)}}}function Y(t,e,r){let{stores:s}=e,{page:n}=e,{components:o}=e,{props_0:a=null}=e,{props_1:i=null}=e,{props_2:l=null}=e;j("__svelte__",s),P(s.page.notify);let c=!1,u=!1,h=null;return A((()=>{const t=s.page.subscribe((()=>{c&&(r(5,u=!0),r(6,h=document.title||"untitled page"))}));return r(4,c=!0),t})),t.$$set=t=>{"stores"in t&&r(7,s=t.stores),"page"in t&&r(8,n=t.page),"components"in t&&r(0,o=t.components),"props_0"in t&&r(1,a=t.props_0),"props_1"in t&&r(2,i=t.props_1),"props_2"in t&&r(3,l=t.props_2)},t.$$.update=()=>{384&t.$$.dirty&&s.page.set(n)},[o,a,i,l,c,u,h,s,n]}class G extends l{constructor(t){super(),c(this,t,Y,M,u,{stores:7,page:8,components:0,props_0:1,props_1:2,props_2:3})}}let J;const X={},F=function(t,e){if(!e)return t();if(void 0===J){const t=document.createElement("link").relList;J=t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"}return Promise.all(e.map((t=>{if(t in X)return;X[t]=!0;const e=t.endsWith(".css"),r=e?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${t}"]${r}`))return;const s=document.createElement("link");return s.rel=e?"stylesheet":J,e||(s.as="script",s.crossOrigin=""),s.href=t,document.head.appendChild(s),e?new Promise(((t,e)=>{s.addEventListener("load",t),s.addEventListener("error",e)})):void 0}))).then((()=>t()))},H=[()=>F((()=>import("./layout.svelte-8ff5a2d3.js")),["/aotds-docks/_app/layout.svelte-8ff5a2d3.js","/aotds-docks/_app/chunks/vendor-d7482fce.js"]),()=>F((()=>import("./error.svelte-26494c7d.js")),["/aotds-docks/_app/error.svelte-26494c7d.js","/aotds-docks/_app/chunks/vendor-d7482fce.js"]),()=>F((()=>import("./pages/index.svelte-4e24bb6e.js")),["/aotds-docks/_app/pages/index.svelte-4e24bb6e.js","/aotds-docks/_app/assets/pages/index.svelte-90c8a385.css","/aotds-docks/_app/chunks/vendor-d7482fce.js","/aotds-docks/_app/chunks/paths-45dac81d.js"])],Q=[[/^\/$/,[H[0],H[2]],[H[1]]]],Z=[H[0](),H[1]()];function tt(){return{x:pageXOffset,y:pageYOffset}}function et(t){for(;t&&"A"!==t.nodeName.toUpperCase();)t=t.parentNode;return t}class rt{constructor({base:t,routes:e,trailing_slash:r}){this.base=t,this.routes=e,this.trailing_slash=r}init(t){let s;this.renderer=t,t.router=this,this.enabled=!0,"scrollRestoration"in history&&(history.scrollRestoration="manual"),addEventListener("beforeunload",(()=>{history.scrollRestoration="auto"})),addEventListener("load",(()=>{history.scrollRestoration="manual"})),addEventListener("scroll",(()=>{clearTimeout(s),s=setTimeout((()=>{const t=(s=i({},history.state||{}),n={"sveltekit:scroll":tt()},e(s,r(n)));var s,n;history.replaceState(t,document.title,window.location.href)}),50)}));const n=t=>{const e=et(t.target);e&&e.href&&e.hasAttribute("sveltekit:prefetch")&&this.prefetch(new URL(e.href))};let o;addEventListener("touchstart",n),addEventListener("mousemove",(t=>{clearTimeout(o),o=setTimeout((()=>{n(t)}),20)})),addEventListener("click",(t=>{var e;if(!this.enabled)return;if(t.button||1!==t.which)return;if(t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;if(t.defaultPrevented)return;const r=et(t.target);if(!r)return;if(!r.href)return;const s="object"==typeof r.href&&"SVGAnimatedString"===r.href.constructor.name,n=String(s?r.href.baseVal:r.href);if(n===location.href)return void(location.hash||t.preventDefault());const o=null==(e=r.getAttribute("rel"))?void 0:e.split(/\s+/);if(r.hasAttribute("download")||o&&o.includes("external"))return;if(s?r.target.baseVal:r.target)return;const a=new URL(n);if(!this.owns(a))return;const i=r.hasAttribute("sveltekit:noscroll");history.pushState({},"",a.href),this._navigate(a,i?tt():null,[],a.hash),t.preventDefault()})),addEventListener("popstate",(t=>{if(t.state&&this.enabled){const e=new URL(location.href);this._navigate(e,t.state["sveltekit:scroll"],[])}})),document.body.setAttribute("tabindex","-1"),history.replaceState(history.state||{},"",location.href)}owns(t){return t.origin===location.origin&&t.pathname.startsWith(this.base)}parse(t){if(this.owns(t)){const e=decodeURIComponent(t.pathname.slice(this.base.length)||"/"),r=this.routes.filter((([t])=>t.test(e))),s=new URLSearchParams(t.search);return{id:`${e}?${s}`,routes:r,path:e,query:s}}}async goto(t,{noscroll:e=!1,replaceState:r=!1,state:s={}}={},n){const o=new URL(t,function(t){let e=t.baseURI;if(!e){const r=t.getElementsByTagName("base");e=r.length?r[0].href:t.URL}return e}(document));return this.enabled&&this.owns(o)?(history[r?"replaceState":"pushState"](s,"",t),this._navigate(o,e?tt():null,n,o.hash)):(location.href=o.href,new Promise((()=>{})))}enable(){this.enabled=!0}disable(){this.enabled=!1}async prefetch(t){const e=this.parse(t);if(!e)throw new Error("Attempted to prefetch a URL that does not belong to this app");return this.renderer.load(e)}async _navigate(t,e,r,s){const n=this.parse(t);if(!n)throw new Error("Attempted to navigate to a URL that does not belong to this app");if("/"!==n.path){const t=n.path.endsWith("/");(t&&"never"===this.trailing_slash||!t&&"always"===this.trailing_slash&&!n.path.split("/").pop().includes("."))&&(n.path=t?n.path.slice(0,-1):n.path+"/",history.replaceState({},"",`${this.base}${n.path}${location.search}`))}this.renderer.notify({path:n.path,query:n.query}),await this.renderer.update(n,r,!1),document.body.focus();const o=s&&document.getElementById(s.slice(1));e?scrollTo(e.x,e.y):o?scrollTo(0,o.getBoundingClientRect().top+scrollY):scrollTo(0,0)}}function st(t){const e=C(t);let r=!0;return{notify:function(){r=!0,e.update((t=>t))},set:function(t){r=!1,e.set(t)},subscribe:function(t){let s;return e.subscribe((e=>{(void 0===s||r&&e!==s)&&t(s=e)}))}}}function nt(t,e){let r=`script[type="svelte-data"][url="${"string"==typeof t?t:t.url}"]`;e&&"string"==typeof e.body&&(r+=`[body="${function(t){let e=5381,r=t.length;if("string"==typeof t)for(;r;)e=33*e^t.charCodeAt(--r);else for(;r;)e=33*e^t[--r];return(e>>>0).toString(36)}(e.body)}"]`);const a=document.querySelector(r);if(a){const t=JSON.parse(a.textContent),{body:e}=t,r=((t,e)=>{var r={};for(var a in t)n.call(t,a)&&e.indexOf(a)<0&&(r[a]=t[a]);if(null!=t&&s)for(var a of s(t))e.indexOf(a)<0&&o.call(t,a)&&(r[a]=t[a]);return r})(t,["body"]);return Promise.resolve(new Response(e,r))}return fetch(t,e)}class ot{constructor({Root:t,fallback:e,target:r,session:s,host:n}){this.Root=t,this.fallback=e,this.host=n,this.router=null,this.target=r,this.started=!1,this.session_id=1,this.invalid=new Set,this.invalidating=null,this.current={page:null,session_id:null,branch:[]},this.cache=new Map,this.loading={id:null,promise:null},this.stores={page:st({}),navigating:C(null),session:C(s)},this.$session=null,this.root=null;let o=!1;this.stores.session.subscribe((async t=>{if(this.$session=t,!o)return;this.session_id+=1;const e=this.router.parse(new URL(location.href));this.update(e,[],!0)})),o=!0}async start({status:t,error:e,nodes:r,page:s}){const n=[];let o,a,l,c={};try{for(let o=0;o10||e.includes(t.path)))return void(this.router?this.router.goto(n.redirect,{replaceState:!0},[...e,t.path]):location.href=new URL(n.redirect,location.href).href);n=await this._load_error({status:500,error:new Error("Redirect loop"),path:t.path,query:t.query})}n.reload?location.reload():this.started?(this.current=n.state,this.root.$set(n.props),this.stores.navigating.set(null),await 0):this._init(n),dispatchEvent(new CustomEvent("sveltekit:navigation-end")),this.loading.promise=null,this.loading.id=null;const o=n.state.branch[n.state.branch.length-1];o&&!1===o.module.router?this.router.disable():this.router.enable()}load(t){return this.loading.promise=this._get_navigation_result(t,!1),this.loading.id=t.id,this.loading.promise}invalidate(t){return this.invalid.add(t),this.invalidating||(this.invalidating=Promise.resolve().then((async()=>{const t=this.router.parse(new URL(location.href));await this.update(t,[],!0),this.invalidating=null}))),this.invalidating}_init(t){this.current=t.state;const e=document.querySelector("style[data-svelte]");e&&e.remove(),this.root=new this.Root({target:this.target,props:i({stores:this.stores},t.props),hydrate:!0}),this.started=!0}async _get_navigation_result(t,e){if(this.loading.id===t.id)return this.loading.promise;for(let r=0;rt())),n+=1}const o=await this._load({route:s,path:t.path,query:t.query},e);if(o)return o}return await this._load_error({status:404,error:new Error(`Not found: ${t.path}`),path:t.path,query:t.query})}async _get_navigation_result_from_branch({page:t,branch:e}){const r=e.filter(Boolean),s={state:{page:t,branch:e,session_id:this.session_id},props:{components:r.map((t=>t.module.default))}};for(let a=0;a{this.cache.get(e)===s&&this.cache.delete(e),i(),clearTimeout(a)},a=setTimeout(n,1e3*o),i=this.stores.session.subscribe((()=>{r&&n()}));r=!0,this.cache.set(e,s)}return s}async _load_node({status:t,error:e,module:r,page:s,context:n}){const o={module:r,uses:{params:new Set,path:!1,query:!1,session:!1,context:!1,dependencies:[]},loaded:null,context:n},a={};for(const i in s.params)Object.defineProperty(a,i,{get:()=>(o.uses.params.add(i),s.params[i]),enumerable:!0});const l=this.$session;if(r.load){const{started:c}=this,u={page:{host:s.host,params:a,get path(){return o.uses.path=!0,s.path},get query(){return o.uses.query=!0,s.query}},get session(){return o.uses.session=!0,l},get context(){return o.uses.context=!0,i({},n)},fetch(t,e){const r="string"==typeof t?t:t.url,{href:n}=new URL(r,new URL(s.path,document.baseURI));return o.uses.dependencies.push(n),c?fetch(t,e):nt(t,e)}};e&&(u.status=t,u.error=e);const h=await r.load.call(null,u);if(!h)return;o.loaded=function(t){if(t.error){const e="string"==typeof t.error?new Error(t.error):t.error,r=t.status;return e instanceof Error?!r||r<400||r>599?(console.warn('"error" returned from load() without a valid status code — defaulting to 500'),{status:500,error:e}):{status:r,error:e}:{status:500,error:new Error(`"error" property returned from load() must be a string or instance of Error, received type "${typeof e}"`)}}if(t.redirect){if(!t.status||3!==Math.floor(t.status/100))return{status:500,error:new Error('"redirect" property returned from load() must be accompanied by a 3xx status code')};if("string"!=typeof t.redirect)return{status:500,error:new Error('"redirect" property returned from load() must be a string')}}return t}(h),o.loaded.context&&(o.context=o.loaded.context)}return o}async _load({route:t,path:e,query:r},s){const n=`${e}?${r}`;if(!s&&this.cache.has(n))return this.cache.get(n);const[o,a,l,c]=t,u=c?c(o.exec(e)):{},h=this.current.page&&{path:e!==this.current.page.path,params:Object.keys(u).filter((t=>this.current.page.params[t]!==u[t])),query:r.toString()!==this.current.page.query.toString(),session:this.session_id!==this.current.session_id},d={host:this.host,path:e,query:r,params:u},p=[];let f={},g=!1,m=200,y=null;a.forEach((t=>t()));t:for(let v=0;vr.uses.params.has(t)))||h.query&&r.uses.query||h.session&&r.uses.session||r.uses.dependencies.some((t=>this.invalid.has(t)))||g&&r.uses.context){t=await this._load_node({module:e,page:d,context:f});const r=v===a.length-1;if(t&&t.loaded){if(t.loaded.error&&(m=t.loaded.status,y=t.loaded.error),t.loaded.redirect)return{redirect:t.loaded.redirect};t.loaded.context&&(g=!0)}else if(r&&e.load)return}else t=r}catch(_){m=500,y=_}if(y){for(;v--;)if(l[v]){let t,e,r=v;for(;!(e=p[r]);)r-=1;try{if(t=await this._load_node({status:m,error:y,module:await l[v](),page:d,context:e.context}),t.loaded.error)continue;p.push(t);break t}catch(_){continue}}return await this._load_error({status:m,error:y,path:e,query:r})}t&&t.loaded&&t.loaded.context&&(f=i(i({},f),t.loaded.context)),p.push(t)}return await this._get_navigation_result_from_branch({page:d,branch:p})}async _load_error({status:t,error:e,path:r,query:s}){const n={host:this.host,path:r,query:s,params:{}},o=await this._load_node({module:await this.fallback[0],page:n,context:{}}),a=[o,await this._load_node({status:t,error:e,module:await this.fallback[1],page:n,context:o&&o.loaded&&o.loaded.context})];return await this._get_navigation_result_from_branch({page:n,branch:a})}}async function at({paths:t,target:e,session:r,host:s,route:n,spa:o,trailing_slash:a,hydrate:i}){const l=n&&new rt({base:t.base,routes:Q,trailing_slash:a}),c=new ot({Root:G,fallback:Z,target:e,session:r,host:s});I(t),i&&await c.start(i),n&&l.init(c),o&&l.goto(location.href,{replaceState:!0},[]),dispatchEvent(new CustomEvent("sveltekit:start"))}export{at as start}; diff --git a/docs/index.html b/docs/index.html index 02807d8..2e40e16 100644 --- a/docs/index.html +++ b/docs/index.html @@ -8,16 +8,16 @@ - + - + - +