Files
tutortool/frontend/build/_app/immutable/chunks/BYEkGdSH.js
T

1 line
2.8 KiB
JavaScript

import{$ as e,B as t,D as n,E as r,F as i,I as a,J as o,L as s,Q as c,R as l,S as u,T as d,V as f,Y as p,_ as m,f as h,g,h as _,i as v,j as y,u as b,v as x,w as S,y as C}from"./egdMPJ-g.js";import"./BMRk7WTg.js";var w=u(`<defs><pattern id="grid" patternUnits="userSpaceOnUse"><path fill="none" stroke="#eee" stroke-width="1"></path></pattern></defs><rect width="100%" height="100%" fill="url(#grid)"></rect>`,1),T=u(`<text text-anchor="middle" class="student-name svelte-1i40qao"> </text>`),E=u(`<rect rx="4" class="svelte-1i40qao"></rect><text text-anchor="middle" dominant-baseline="middle" class="svelte-1i40qao"> </text><!>`,1),D=u(`<rect fill="#e9ecef" stroke="#dee2e6" class="svelte-1i40qao"></rect>`),O=u(`<rect fill="#ffeeba" stroke="#ffe082" class="svelte-1i40qao"></rect><text text-anchor="middle" dominant-baseline="middle" style="font-size: 10px;" class="svelte-1i40qao">DOOR</text>`,1),k=u(`<g><!></g>`),A=u(`<svg width="800" height="600"><!><!></svg>`);function j(u,S){p(S,!0);let j=v(S,`elements`,31,()=>l([])),M=v(S,`editable`,3,!1),N=v(S,`selectedId`,3,null),P=v(S,`occupiedSeatIds`,19,()=>[]),F=v(S,`mySeatId`,3,null),I=v(S,`studentNames`,19,()=>({})),L=f(null),R=0,z=0;function B(e,n){if(!M()){S.onElementClick?.(n);return}t(L,n.id,!0),R=e.clientX-n.x*40,z=e.clientY-n.y*40}function V(e){if(!n(L)||!M())return;let t=j().findIndex(e=>e.id===n(L));if(t===-1)return;let r=Math.round((e.clientX-R)/10)*10/40,i=Math.round((e.clientY-z)/10)*10/40;j(j()[t]={...j()[t],x:r,y:i},!0)}function H(){n(L)&&M()&&S.onLayoutChange?.(j()),t(L,null)}var U=A();let W;var G=i(U),K=t=>{var n=w(),r=a(n),o=i(r);b(o,`width`,40),b(o,`height`,40),b(i(o),`d`,`M 40 0 L 0 0 0 40`),e(o),e(r),c(),C(t,n)};m(G,e=>{M()&&e(K)}),_(s(G),17,j,g,(t,r)=>{var o=k();let c;var l=i(o),u=t=>{var o=E(),c=a(o),l=s(c),u=i(l,!0);e(l);var d=s(l),f=t=>{var a=T(),o=i(a,!0);e(a),y(()=>{b(a,`x`,n(r).width*40/2),b(a,`y`,n(r).height*40+15),x(o,I()[n(r).id])}),C(t,a)};m(d,e=>{I()[n(r).id]&&e(f)}),y(()=>{b(c,`width`,n(r).width*40),b(c,`height`,n(r).height*40),b(l,`x`,n(r).width*40/2),b(l,`y`,n(r).height*40/2),x(u,n(r).label)}),C(t,o)},f=e=>{var t=D();y(()=>{b(t,`width`,n(r).width*40),b(t,`height`,n(r).height*40)}),C(e,t)},p=e=>{var t=O(),i=a(t),o=s(i);y(()=>{b(i,`width`,n(r).width*40),b(i,`height`,n(r).height*40),b(o,`x`,n(r).width*40/2),b(o,`y`,n(r).height*40/2)}),C(e,t)};m(l,e=>{n(r).type===`seat`?e(u):n(r).type===`table`?e(f,1):n(r).type===`door`&&e(p,2)}),e(o),y(e=>{b(o,`transform`,`translate(${n(r).x*40}, ${n(r).y*40})`),c=h(o,0,`element ${n(r).type??``}`,`svelte-1i40qao`,c,e)},[()=>({selected:N()===n(r).id,occupied:n(r).type===`seat`&&P().includes(n(r).id),"is-mine":n(r).id===F()})]),d(`mousedown`,o,e=>B(e,n(r))),C(t,o)}),e(U),y(()=>W=h(U,0,`room-canvas svelte-1i40qao`,null,W,{editable:M()})),d(`mousemove`,U,V),d(`mouseup`,U,H),r(`mouseleave`,U,H),C(u,U),o()}S([`mousemove`,`mouseup`,`mousedown`]);export{j as t};