1import{S as x,i as ee,s as G,A as Q,B as d,f as C,D as H,E as W,p as v,a6 as It,F as q,K as Y,q as me,b as R,a3 as Xe,ah as Ke,a5 as $e,C as yt,O as N,I as P,ad as Ct,a2 as bt,G as U,ak as kt,o as p,k as Z,t as A,n as K,N as vt,r as pt,V as ge,ac as zt,x as ce,c as T,m as B,l as S,M as Le,an as Mt,e as oe,j as V,a as X,W as Tt,X as Bt,Y as St,Z as Dt,v as Et,a7 as Rt,g as jt,h as Lt}from"./index.a6771086.js";import{a as Ut}from"./Empty.svelte_svelte_type_style_lang.d6377f22.js";import{B as wt}from"./BlockLabel.b490a462.js";/* empty css */import{I as Ue}from"./Image.10222f9e.js";import{C as qt,i as Nt,U as Ft,W as Wt}from"./StaticImage.svelte_svelte_type_style_lang.c56d4a8c.js";import{I as pe,C as Ot,M as qe}from"./ModifyUpload.40e06d67.js";import{U as Ht}from"./Upload.939ad04f.js";import{E as Yt}from"./Empty.b61eaa47.js";import{D as Jt}from"./Download.90e0faa4.js";import"./Blocks.3a83d8d3.js";import{U as Pt}from"./UploadText.d45af78a.js";import{E as ns}from"./Image.38efec31.js";import"./ModifyUpload.svelte_svelte_type_style_lang.e946db2d.js";function Vt(t){let e,n,s;return{c(){e=Q("svg"),n=Q("path"),s=Q("path"),d(n,"d","M28.828 3.172a4.094 4.094 0 0 0-5.656 0L4.05 22.292A6.954 6.954 0 0 0 2 27.242V30h2.756a6.952 6.952 0 0 0 4.95-2.05L28.828 8.829a3.999 3.999 0 0 0 0-5.657zM10.91 18.26l2.829 2.829l-2.122 2.121l-2.828-2.828zm-2.619 8.276A4.966 4.966 0 0 1 4.756 28H4v-.759a4.967 4.967 0 0 1 1.464-3.535l1.91-1.91l2.829 2.828zM27.415 7.414l-12.261 12.26l-2.829-2.828l12.262-12.26a2.047 2.047 0 0 1 2.828 0a2 2 0 0 1 0 2.828z"),d(n,"fill","currentColor"),d(s,"d","M6.5 15a3.5 3.5 0 0 1-2.475-5.974l3.5-3.5a1.502 1.502 0 0 0 0-2.121a1.537 1.537 0 0 0-2.121 0L3.415 5.394L2 3.98l1.99-1.988a3.585 3.585 0 0 1 4.95 0a3.504 3.504 0 0 1 0 4.949L5.439 10.44a1.502 1.502 0 0 0 0 2.121a1.537 1.537 0 0 0 2.122 0l4.024-4.024L13 9.95l-4.025 4.024A3.475 3.475 0 0 1 6.5 15z"),d(s,"fill","currentColor"),d(e,"width","100%"),d(e,"height","100%"),d(e,"viewBox","0 0 32 32")},m(i,u){C(i,e,u),H(e,n),H(e,s)},p:W,i:W,o:W,d(i){i&&v(e)}}}class Xt extends x{constructor(e){super(),ee(this,e,null,Vt,G,{})}}function Qt(t){let e,n,s,i,u,r,o;return{c(){e=Q("svg"),n=Q("circle"),s=Q("circle"),i=Q("circle"),u=Q("circle"),r=Q("circle"),o=Q("path"),d(n,"cx","10"),d(n,"cy","12"),d(n,"r","2"),d(n,"fill","currentColor"),d(s,"cx","16"),d(s,"cy","9"),d(s,"r","2"),d(s,"fill","currentColor"),d(i,"cx","22"),d(i,"cy","12"),d(i,"r","2"),d(i,"fill","currentColor"),d(u,"cx","23"),d(u,"cy","18"),d(u,"r","2"),d(u,"fill","currentColor"),d(r,"cx","19"),d(r,"cy","23"),d(r,"r","2"),d(r,"fill","currentColor"),d(o,"fill","currentColor"),d(o,"d","M16.54 2A14 14 0 0 0 2 16a4.82 4.82 0 0 0 6.09 4.65l1.12-.31a3 3 0 0 1 3.79 2.9V27a3 3 0 0 0 3 3a14 14 0 0 0 14-14.54A14.05 14.05 0 0 0 16.54 2Zm8.11 22.31A11.93 11.93 0 0 1 16 28a1 1 0 0 1-1-1v-3.76a5 5 0 0 0-5-5a5.07 5.07 0 0 0-1.33.18l-1.12.31A2.82 2.82 0 0 1 4 16A12 12 0 0 1 16.47 4A12.18 12.18 0 0 1 28 15.53a11.89 11.89 0 0 1-3.35 8.79Z"),d(e,"width","100%"),d(e,"height","100%"),d(e,"viewBox","0 0 32 32")},m(l,h){C(l,e,h),H(e,n),H(e,s),H(e,i),H(e,u),H(e,r),H(e,o)},p:W,i:W,o:W,d(l){l&&v(e)}}}class Gt extends x{constructor(e){super(),ee(this,e,null,Qt,G,{})}}function Zt(t){let e,n;return{c(){e=Q("svg"),n=Q("path"),d(n,"d","M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"),d(e,"xmlns","http://www.w3.org/2000/svg"),d(e,"width","100%"),d(e,"height","100%"),d(e,"viewBox","0 0 24 24"),d(e,"fill","none"),d(e,"stroke","currentColor"),d(e,"stroke-width","1.5"),d(e,"stroke-linecap","round"),d(e,"stroke-linejoin","round"),d(e,"class","feather feather-edit-2")},m(s,i){C(s,e,i),H(e,n)},p:W,i:W,o:W,d(s){s&&v(e)}}}class xe extends x{constructor(e){super(),ee(this,e,null,Zt,G,{})}}function Kt(t){let e,n;return{c(){e=q("img"),Y(e.src,n=t[0])||d(e,"src",n),d(e,"alt","")},m(s,i){C(s,e,i),t[4](e)},p(s,[i]){i&1&&!Y(e.src,n=s[0])&&d(e,"src",n)},i:W,o:W,d(s){s&&v(e),t[4](null)}}}function $t(t,e,n){let{image:s}=e,i;const u=me();let r;function o(){r.destroy()}function l(){r&&o(),r=new qt(i,{autoCropArea:1,cropend(){const f=r.getCroppedCanvas().toDataURL();u("crop",f)}}),u("crop",s)}function h(f){R[f?"unshift":"push"](()=>{i=f,n(1,i)})}return t.$$set=f=>{"image"in f&&n(0,s=f.image)},[s,i,o,l,h]}class At extends x{constructor(e){super(),ee(this,e,$t,Kt,G,{image:0,destroy:2,create:3})}get image(){return this.$$.ctx[0]}set image(e){this.$$set({image:e}),It()}get destroy(){return this.$$.ctx[2]}get create(){return this.$$.ctx[3]}}class et{constructor(e,n){this.x=e,this.y=n}}class tt extends et{update(e){this.x=e.x,this.y=e.y}moveByAngle(e,n){const s=e+Math.PI/2;this.x=this.x+Math.sin(s)*n,this.y=this.y-Math.cos(s)*n}equalsTo(e){return this.x===e.x&&this.y===e.y}getDifferenceTo(e){return new et(this.x-e.x,this.y-e.y)}getDistanceTo(e){const n=this.getDifferenceTo(e);return Math.sqrt(Math.pow(n.x,2)+Math.pow(n.y,2))}getAngleTo(e){const n=this.getDifferenceTo(e);return Math.atan2(n.y,n.x)}toObject(){return{x:this.x,y:this.y}}}const xt=30;class en{constructor({radius:e=xt,enabled:n=!0,initialPoint:s={x:0,y:0}}={}){this.radius=e,this._isEnabled=n,this.pointer=new tt(s.x,s.y),this.brush=new tt(s.x,s.y),this.angle=0,this.distance=0,this._hasMoved=!1}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}isEnabled(){return this._isEnabled}setRadius(e){this.radius=e}getRadius(){return this.radius}getBrushCoordinates(){return this.brush.toObject()}getPointerCoordinates(){return this.pointer.toObject()}getBrush(){return this.brush}getPointer(){return this.pointer}getAngle(){return this.angle}getDistance(){return this.distance}brushHasMoved(){return this._hasMoved}update(e,{both:n=!1}={}){return this._hasMoved=!1,this.pointer.equalsTo(e)&&!n?!1:(this.pointer.update(e),n?(this._hasMoved=!0,this.brush.update(e),!0):(this._isEnabled?(this.distance=this.pointer.getDistanceTo(this.brush),this.angle=this.pointer.getAngleTo(this.brush),this.distance>this.radius&&(this.brush.moveByAngle(this.angle,this.distance-this.radius),this._hasMoved=!0)):(this.distance=0,this.angle=0,this.brush.update(e),this._hasMoved=!0),!0))}}function nt(t,e,n){const s=t.slice();return s[59]=e[n].name,s[60]=e[n].zIndex,s[61]=e,s[62]=n,s}function st(t){let e,n,s;return{c(){e=q("div"),e.textContent="Start drawing",d(e,"class","start-prompt svelte-yigbas")},m(i,u){C(i,e,u),s=!0},i(i){s||(Xe(()=>{n||(n=Ke(e,$e,{duration:50},!0)),n.run(1)}),s=!0)},o(i){n||(n=Ke(e,$e,{duration:50},!1)),n.run(0),s=!1},d(i){i&&v(e),i&&n&&n.end()}}}function rt(t){let e,n,s=t[59],i,u;const r=()=>t[29](e,s),o=()=>t[29](null,s);return{c(){e=q("canvas"),d(e,"key",n=t[59]),yt(e,"z-index",t[60]),d(e,"class","svelte-yigbas"),N(e,"lr",t[5]),N(e,"tb",!t[5])},m(l,h){C(l,e,h),r(),i||(u=[P(e,"mousedown",t[59]==="interface"?t[7]:void 0),P(e,"mousemove",t[59]==="interface"?t[8]:void 0),P(e,"mouseup",t[59]==="interface"?t[9]:void 0),P(e,"mouseout",t[59]==="interface"?t[9]:void 0),P(e,"blur",t[59]==="interface"?t[9]:void 0),P(e,"touchstart",t[59]==="interface"?t[7]:void 0),P(e,"touchmove",t[59]==="interface"?t[8]:void 0),P(e,"touchend",t[59]==="interface"?t[9]:void 0),P(e,"touchcancel",t[59]==="interface"?t[9]:void 0),P(e,"click",Ct(t[28]))],i=!0)},p(l,h){t=l,s!==t[59]&&(o(),s=t[59],r()),h[0]&32&&N(e,"lr",t[5]),h[0]&32&&N(e,"tb",!t[5])},d(l){l&&v(e),o(),i=!1,bt(u)}}}function tn(t){let e,n,s,i,u=t[4]===0&&st(),r=t[6],o=[];for(let l=0;l<r.length;l+=1)o[l]=rt(nt(t,r,l));return{c(){e=q("div"),u&&u.c(),n=U();for(let l=0;l<o.length;l+=1)o[l].c();d(e,"class","wrap svelte-yigbas"),Xe(()=>t[31].call(e))},m(l,h){C(l,e,h),u&&u.m(e,null),H(e,n);for(let f=0;f<o.length;f+=1)o[f].m(e,null);t[30](e),s=kt(e,t[31].bind(e)),i=!0},p(l,h){if(l[4]===0?u?h[0]&16&&p(u,1):(u=st(),u.c(),p(u,1),u.m(e,n)):u&&(Z(),A(u,1,1,()=>{u=null}),K()),h[0]&993){r=l[6];let f;for(f=0;f<r.length;f+=1){const g=nt(l,r,f);o[f]?o[f].p(g,h):(o[f]=rt(g),o[f].c(),o[f].m(e,null))}for(;f<o.length;f+=1)o[f].d(1);o.length=r.length}},i(l){i||(p(u),i=!0)},o(l){A(u),i=!1},d(l){l&&v(e),u&&u.d(),vt(o,l),t[30](null),s()}}}let nn="#aaa";function it(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}function sn(t,e,n){let s;const i=me();let{value:u}=e,{value_img:r}=e,{mode:o="sketch"}=e,{brush_color:l="#0b0f19"}=e,{brush_radius:h}=e,{source:f}=e,{width:g=400}=e,{height:a=200}=e,{container_height:_=200}=e,{shape:b}=e,I,M=g,j=a,te;const ae=[{name:"interface",zIndex:15},{name:"drawing",zIndex:11},{name:"temp",zIndex:12},{name:"mask",zIndex:-1},{name:"temp_fake",zIndex:-2}];let E={},k={},F=[],O=[],ie=!0,ne=!0,se=!1,re=!1,D=null,w=null,fe=null,le=0;function $(){if(!b){k.temp.drawImage(r,0,0,g,a);return}
1let m=r.naturalWidth,y=r.naturalHeight;const c=b[0]/b[1],z=m/y;let L=0,J=0;c<z?(m=b[1]*z,y=b[1],L=(b[0]-m)/2):c>z?(m=b[0],y=b[0]/z,J=(b[1]-y)/2):(L=0,J=0,m=b[0],y=b[1]),k.temp.drawImage(r,L,J,m,y)}pt(async()=>{Object.keys(E).forEach(m=>{n(25,k[m]=E[m].getContext("2d"),k)}),await ge(),r&&(r.addEventListener("load",m=>{f==="webcam"?(k.temp.save(),k.temp.translate(g,0),k.temp.scale(-1,1),k.temp.drawImage(r,0,0),k.temp.restore()):$(),k.drawing.drawImage(E.temp,0,0,g,a),ue()}),setTimeout(()=>{f==="webcam"?(k.temp.save(),k.temp.translate(g,0),k.temp.scale(-1,1),k.temp.drawImage(r,0,0),k.temp.restore()):$(),k.drawing.drawImage(E.temp,0,0,g,a),de({lines:O.slice()}),ue()},100)),n(27,D=new en({radius:h*.05,enabled:!0,initialPoint:{x:g/2,y:a/2}})),fe=new Nt((m,y,...c)=>{ze(m,y)}),fe.observe(w),be(),n(23,I=!0),requestAnimationFrame(()=>{we(),requestAnimationFrame(()=>{he()})})});function we(){const m=g/2,y=a/2;D.update({x:m,y},{both:!0}),D.update({x:m,y},{both:!1}),ie=!0,ne=!0}zt(()=>{n(23,I=!1),fe.unobserve(w)});function Ne(){const m=O.slice(0,-1);Re(),r&&(f==="webcam"?(k.temp.save(),k.temp.translate(g,0),k.temp.scale(-1,1),k.temp.drawImage(r,0,0),k.temp.restore()):$(),(!O||!O.length)&&k.drawing.drawImage(E.temp,0,0,g,a)),de({lines:m}),n(4,le=m.length),O.length&&n(26,O=m),O.length==0&&i("clear"),ue()}let de=({lines:m})=>{m.forEach(y=>{const{points:c,brush_color:z,brush_radius:L}=y;Be({points:c,brush_color:z,brush_radius:L}),o==="mask"&&Se({points:c,brush_color:z,brush_radius:L}),F=c}),Ee({brush_color:l,brush_radius:h}),o==="mask"&&De()},Fe=m=>{m.preventDefault(),re=!0;const{x:y,y:c}=Me(m);m.touches&&m.touches.length>0&&D.update({x:y,y:c},{both:!0}),Te(y,c),n(4,le+=1)},Ae=m=>{m.preventDefault();const{x:y,y:c}=Me(m);Te(y,c)},We=m=>{m.preventDefault(),Ae(m),se=!1,re=!1,Ee(),o==="mask"&&De()},Ie=0,ye=0,Ce=0,ve=!1,ze=async()=>{if(b&&w){const c=w?.getBoundingClientRect(),z=b[0]/b[1],L=c.width/c.height;n(5,ve=z<L)}if(g===Ie&&a===ye&&Ce===_)return;const m={width:g,height:a},y={height:_,width:_*(m.width/m.height)};await Promise.all([_e(E.interface,m,y),_e(E.drawing,m,y),_e(E.temp,m,y),_e(E.temp_fake,m,y),_e(E.mask,m,y,!1)]),h||n(10,h=20*(m.width/y.width)),be({once:!0}),setTimeout(()=>{ye=a,Ie=g,Ce=_},10),await ge(),he()},_e=async(m,y,c,z=!0)=>{if(!I)return;await ge();const L=window.devicePixelRatio||1;m.width=y.width*(z?L:1),m.height=y.height*(z?L:1);const J=m.getContext("2d");z&&J.scale(L,L),m.style.width=`${c.width}px`,m.style.height=`${c.height}px`},Me=m=>{const y=E.interface.getBoundingClientRect();let c=m.clientX,z=m.clientY;return m.changedTouches&&m.changedTouches.length>0&&(c=m.changedTouches[0].clientX,z=m.changedTouches[0].clientY),{x:(c-y.left)/y.width*g,y:(z-y.top)/y.height*a}},Te=(m,y)=>{D.update({x:m,y});const c=!D.isEnabled();(re&&!se||c&&re)&&(se=!0,F.push(D.brush.toObject())),se&&(F.push(D.brush.toObject()),Be({points:F,brush_color:l,brush_radius:h}),o==="mask"&&Se({points:F,brush_color:l,brush_radius:h})),ie=!0},Be=({points:m,brush_color:y,brush_radius:c})=>{if(!m||m.length<2||(n(25,k.temp.lineJoin="round",k),n(25,k.temp.lineCap="round",k),n(25,k.temp.strokeStyle=y,k),n(25,k.temp.lineWidth=c,k),!m||m.length<2))return;let z=m[0],L=m[1];k.temp.moveTo(L.x,L.y),k.temp.beginPath();for(var J=1,Ve=m.length;J<Ve;J++){var ke=it(z,L);k.temp.quadraticCurveTo(z.x,z.y,ke.x,ke.y),z=m[J],L=m[J+1]}k.temp.lineTo(z.x,z.y),k.temp.stroke()},Se=({points:m,brush_color:y,brush_radius:c})=>{if(!m||m.length<2)return;n(25,k.temp_fake.lineJoin="round",k),n(25,k.temp_fake.lineCap="round",k),n(25,k.temp_fake.strokeStyle="#fff",k),n(25,k.temp_fake.lineWidth=c,k);let z=m[0],L=m[1];k.temp_fake.moveTo(L.x,L.y),k.temp_fake.beginPath();for(var J=1,Ve=m.length;J<Ve;J++){var ke=it(z,L);k.temp_fake.quadraticCurveTo(z.x,z.y,ke.x,ke.y),z=m[J],L=m[J+1]}k.temp_fake.lineTo(z.x,z.y),k.temp_fake.stroke()},De=()=>{F.length<1||(F.length=0,k.mask.drawImage(E.temp_fake,0,0,g,a),ue())},Ee=()=>{F.length<1||(O.push({points:F.slice(),brush_color:l,brush_radius:h}),o!=="mask"&&(F.length=0),k.drawing.drawImage(E.temp,0,0,g,a),ue())},ue=()=>{const m=je();i("change",m)};function he(){return n(26,O=[]),Re(),n(4,le=0),!0}function Re(){ne=!0,k.temp.clearRect(0,0,g,a),n(25,k.temp.fillStyle=o==="mask"?"transparent":"#FFFFFF",k),k.temp.fillRect(0,0,g,a),o==="mask"&&(k.temp_fake.clearRect(0,0,E.temp_fake.width,E.temp_fake.height),k.mask.clearRect(0,0,g,a),n(25,k.mask.fillStyle="#000",k),k.mask.fillRect(0,0,g,a))}let be=({once:m=!1}={})=>
1{if(ie||ne){const y=D.getPointerCoordinates(),c=D.getBrushCoordinates();Oe(k.interface,y,c),ie=!1,ne=!1}m||window.requestAnimationFrame(()=>{be()})},Oe=(m,y,c)=>{m.clearRect(0,0,g,a),m.beginPath(),m.fillStyle=l,m.arc(c.x,c.y,h/2,0,Math.PI*2,!0),m.fill(),m.beginPath(),m.fillStyle=nn,m.arc(c.x,c.y,s,0,Math.PI*2,!0),m.fill()};function je(){return o==="mask"?E.mask.toDataURL("image/jpg"):E.drawing.toDataURL("image/jpg")}function He(m){ce.call(this,t,m)}function Ye(m,y){R[m?"unshift":"push"](()=>{E[y]=m,n(0,E)})}function Je(m){R[m?"unshift":"push"](()=>{w=m,n(3,w)})}function Pe(){M=this.offsetWidth,j=this.offsetHeight,n(1,M),n(2,j)}return t.$$set=m=>{"value"in m&&n(13,u=m.value),"value_img"in m&&n(14,r=m.value_img),"mode"in m&&n(15,o=m.mode),"brush_color"in m&&n(16,l=m.brush_color),"brush_radius"in m&&n(10,h=m.brush_radius),"source"in m&&n(17,f=m.source),"width"in m&&n(11,g=m.width),"height"in m&&n(12,a=m.height),"container_height"in m&&n(18,_=m.container_height),"shape"in m&&n(19,b=m.shape)},t.$$.update=()=>{t.$$.dirty[0]&530432&&b&&(g||a)&&(n(11,g=b[0]),n(12,a=b[1])),t.$$.dirty[0]&8396800&&I&&!u&&he(),t.$$.dirty[0]&125982721&&I&&r!==te&&(n(24,te=r),he(),setTimeout(()=>{f==="webcam"?(k.temp.save(),k.temp.translate(g,0),k.temp.scale(-1,1),k.temp.drawImage(r,0,0),k.temp.restore()):$(),k.drawing.drawImage(E.temp,0,0,g,a),de({lines:O.slice()}),ue()},50)),t.$$.dirty[0]&134218752&&D&&(we(),D.setRadius(h*.05)),t.$$.dirty[0]&6144&&(g||a)&&ze(),t.$$.dirty[0]&1024&&(s=h*.075)},[E,M,j,w,le,ve,ae,Fe,Ae,We,h,g,a,u,r,o,l,f,_,b,Ne,he,je,I,te,k,O,D,He,Ye,Je,Pe]}class Qe extends x{constructor(e){super(),ee(this,e,sn,tn,G,{value:13,value_img:14,mode:15,brush_color:16,brush_radius:10,source:17,width:11,height:12,container_height:18,shape:19,undo:20,clear:21,get_image_data:22},null,[-1,-1,-1])}get undo(){return this.$$.ctx[20]}get clear(){return this.$$.ctx[21]}get get_image_data(){return this.$$.ctx[22]}}function rn(t){let e,n,s,i,u;return n=new pe({props:{Icon:Ft,label:"Undo"}}),n.$on("click",t[1]),i=new pe({props:{Icon:Ot,label:"Clear"}}),i.$on("click",t[2]),{c(){e=q("div"),T(n.$$.fragment),s=U(),T(i.$$.fragment),d(e,"class","svelte-s6ybro")},m(r,o){C(r,e,o),B(n,e,null),H(e,s),B(i,e,null),u=!0},p:W,i(r){u||(p(n.$$.fragment,r),p(i.$$.fragment,r),u=!0)},o(r){A(n.$$.fragment,r),A(i.$$.fragment,r),u=!1},d(r){r&&v(e),S(n),S(i)}}}function ln(t){const e=me();return[e,()=>e("undo"),i=>{e("clear"),i.stopPropagation()}]}class Ge extends x{constructor(e){super(),ee(this,e,ln,rn,G,{})}}function lt(t){let e,n,s,i,u;return{c(){e=q("input"),d(e,"aria-label","Brush radius"),d(e,"type","range"),d(e,"min",n=.5*(t[2]/t[6])),d(e,"max",s=75*(t[2]/t[6])),d(e,"class","svelte-p4aq0j")},m(r,o){C(r,e,o),Le(e,t[0]),i||(u=[P(e,"change",t[10]),P(e,"input",t[10])],i=!0)},p(r,o){o&68&&n!==(n=.5*(r[2]/r[6]))&&d(e,"min",n),o&68&&s!==(s=75*(r[2]/r[6]))&&d(e,"max",s),o&1&&Le(e,r[0])},d(r){r&&v(e),i=!1,bt(u)}}}function ut(t){let e,n,s,i;n=new pe({props:{Icon:Gt,label:"Select brush color"}}),n.$on("click",t[11]);let u=t[5]&&ot(t);return{c(){e=q("span"),T(n.$$.fragment),s=U(),u&&u.c(),d(e,"class","col svelte-p4aq0j")},m(r,o){C(r,e,o),B(n,e,null),H(e,s),u&&u.m(e,null),i=!0},p(r,o){r[5]?u?u.p(r,o):(u=ot(r),u.c(),u.m(e,null)):u&&(u.d(1),u=null)},i(r){i||(p(n.$$.fragment,r),i=!0)},o(r){A(n.$$.fragment,r),i=!1},d(r){r&&v(e),S(n),u&&u.d()}}}function ot(t){let e,n,s;return{c(){e=q("input"),d(e,"aria-label","Brush color"),d(e,"type","color"),d(e,"class","svelte-p4aq0j")},m(i,u){C(i,e,u),Le(e,t[1]),n||(s=P(e,"input",t[12]),n=!0)},p(i,u){u&2&&Le(e,i[1])},d(i){i&&v(e),n=!1,s()}}}function un(t){let e,n,s,i,u,r;s=new pe({props:{Icon:Xt,label:"Use brush"}}),s.$on("click",t[9]);let o=t[4]&<(t),l=t[3]!=="mask"&&ut(t);return{c(){e=q("div"),n=q("span"),T(s.$$.fragment),i=U(),o&&o.c(),u=U(),l&&l.c(),d(n,"class","brush svelte-p4aq0j"),d(e,"class","wrap svelte-p4aq0j")},m(h,f){C(h,e,f),H(e,n),B(s,n,null),H(n,i),o&&o.m(n,null),H(e,u),l&&l.m(e,null),r=!0},p(h,[f]){h[4]?o?o.p(h,f):(o=lt(h),o.c(),o.m(n,null)):o&&(o.d(1),o=null),h[3]!=="mask"?l?(l.p(h,f),f&8&&p(l,1)):(l=ut(h),l.c(),p(l,1),l.m(e,null)):l&&(Z(),A(l,1,1,()=>{l=null}),K())},i(h){r||(p(s.$$.fragment,h),p(l),r=!0)},o(h){A(s.$$.fragment,h),A(l),r=!1},d(h){h&&v(e),S(s),o&&o.d(),l&&l.d()}}}function on(t,e,n){let s;me();let i=!1,u=!1,{brush_radius:r=20}=e,{brush_color:o="#000"}=e,{container_height:l}=e,{img_width:h}=e,{img_height:f}=e,{mode:g="other"}=e;const a=()=>n(4,i=!i);function _(){r=Mt(this.value),n(0,r)}const b=()=>n(5,u=!u);
1function I(){o=this.value,n(1,o)}return t.$$set=M=>{"brush_radius"in M&&n(0,r=M.brush_radius),"brush_color"in M&&n(1,o=M.brush_color),"container_height"in M&&n(7,l=M.container_height),"img_width"in M&&n(2,h=M.img_width),"img_height"in M&&n(8,f=M.img_height),"mode"in M&&n(3,g=M.mode)},t.$$.update=()=>{t.$$.dirty&388&&n(6,s=l*(h/f))},[r,o,h,g,i,u,s,l,f,a,_,b,I]}class Ze extends x{constructor(e){super(),ee(this,e,on,un,G,{brush_radius:0,brush_color:1,container_height:7,img_width:2,img_height:8,mode:3})}}function an(t){let e,n;return{c(){e=q("img"),Y(e.src,n=t[0].image||t[0])||d(e,"src",n),d(e,"alt",""),d(e,"class","svelte-rlgzoo"),N(e,"webcam",t[5]==="webcam"&&t[9])},m(s,i){C(s,e,i)},p(s,i){i[0]&1&&!Y(e.src,n=s[0].image||s[0])&&d(e,"src",n),i[0]&544&&N(e,"webcam",s[5]==="webcam"&&s[9])},i:W,o:W,d(s){s&&v(e)}}}function fn(t){let e=t[20],n,s,i,u=at(t),r=t[15]>0&&ft(t);return{c(){u.c(),n=U(),r&&r.c(),s=oe()},m(o,l){u.m(o,l),C(o,n,l),r&&r.m(o,l),C(o,s,l),i=!0},p(o,l){l[0]&1048576&&G(e,e=o[20])?(u.d(1),u=at(o),u.c(),u.m(n.parentNode,n)):u.p(o,l),o[15]>0?r?(r.p(o,l),l[0]&32768&&p(r,1)):(r=ft(o),r.c(),p(r,1),r.m(s.parentNode,s)):r&&(Z(),A(r,1,1,()=>{r=null}),K())},i(o){i||(p(r),i=!0)},o(o){A(r),i=!1},d(o){u.d(o),o&&v(n),r&&r.d(o),o&&v(s)}}}function _n(t){let e,n,s,i,u;return e=new qe({props:{editable:!0}}),e.$on("edit",t[49]),e.$on("clear",t[23]),{c(){T(e.$$.fragment),n=U(),s=q("img"),Y(s.src,i=t[0])||d(s,"src",i),d(s,"alt",""),d(s,"class","svelte-rlgzoo"),N(s,"webcam",t[5]==="webcam"&&t[9])},m(r,o){B(e,r,o),C(r,n,o),C(r,s,o),u=!0},p(r,o){(!u||o[0]&1&&!Y(s.src,i=r[0]))&&d(s,"src",i),o[0]&544&&N(s,"webcam",r[5]==="webcam"&&r[9])},i(r){u||(p(e.$$.fragment,r),u=!0)},o(r){A(e.$$.fragment,r),u=!1},d(r){S(e,r),r&&v(n),r&&v(s)}}}function hn(t){let e,n,s,i,u={image:t[0]};return e=new At({props:u}),t[47](e),e.$on("crop",t[24]),s=new qe({}),s.$on("clear",t[48]),{c(){T(e.$$.fragment),n=U(),T(s.$$.fragment)},m(r,o){B(e,r,o),C(r,n,o),B(s,r,o),i=!0},p(r,o){const l={};o[0]&1&&(l.image=r[0]),e.$set(l)},i(r){i||(p(e.$$.fragment,r),p(s.$$.fragment,r),i=!0)},o(r){A(e.$$.fragment,r),A(s.$$.fragment,r),i=!1},d(r){t[47](null),S(e,r),r&&v(n),S(s,r)}}}function cn(t){let e,n,s=t[5]==="webcam"&&!t[20]&&ht(t);return{c(){s&&s.c(),e=oe()},m(i,u){s&&s.m(i,u),C(i,e,u),n=!0},p(i,u){i[5]==="webcam"&&!i[20]?s?(s.p(i,u),u[0]&1048608&&p(s,1)):(s=ht(i),s.c(),p(s,1),s.m(e.parentNode,e)):s&&(Z(),A(s,1,1,()=>{s=null}),K())},i(i){n||(p(s),n=!0)},o(i){A(s),n=!1},d(i){s&&s.d(i),i&&v(e)}}}function mn(t){let e,n,s,i,u,r,o;e=new Ge({}),e.$on("undo",t[39]),e.$on("clear",t[26]);let l=t[1]==="color-sketch"&&ct(t);function h(a){t[42](a)}function f(a){t[43](a)}let g={value:t[0],mode:t[12],width:t[15]||t[19],height:t[14]||t[18],container_height:t[16]||t[18],shape:t[6]};return t[2]!==void 0&&(g.brush_radius=t[2]),t[21]!==void 0&&(g.brush_color=t[21]),i=new Qe({props:g}),R.push(()=>X(i,"brush_radius",h)),R.push(()=>X(i,"brush_color",f)),t[44](i),i.$on("change",t[24]),i.$on("clear",t[26]),{c(){T(e.$$.fragment),n=U(),l&&l.c(),s=U(),T(i.$$.fragment)},m(a,_){B(e,a,_),C(a,n,_),l&&l.m(a,_),C(a,s,_),B(i,a,_),o=!0},p(a,_){a[1]==="color-sketch"?l?(l.p(a,_),_[0]&2&&p(l,1)):(l=ct(a),l.c(),p(l,1),l.m(s.parentNode,s)):l&&(Z(),A(l,1,1,()=>{l=null}),K());const b={};_[0]&1&&(b.value=a[0]),_[0]&4096&&(b.mode=a[12]),_[0]&557056&&(b.width=a[15]||a[19]),_[0]&278528&&(b.height=a[14]||a[18]),_[0]&327680&&(b.container_height=a[16]||a[18]),_[0]&64&&(b.shape=a[6]),!u&&_[0]&4&&(u=!0,b.brush_radius=a[2],V(()=>u=!1)),!r&&_[0]&2097152&&(r=!0,b.brush_color=a[21],V(()=>r=!1)),i.$set(b)},i(a){o||(p(e.$$.fragment,a),p(l),p(i.$$.fragment,a),o=!0)},o(a){A(e.$$.fragment,a),A(l),A(i.$$.fragment,a),o=!1},d(a){S(e,a),a&&v(n),l&&l.d(a),a&&v(s),t[44](null),S(i,a)}}}function gn(t){let e,n,s;function i(r){t[38](r)}let u={filetype:"image/*",include_file_metadata:!1,disable_click:!!t[0],$$slots:{default:[An]},$$scope:{ctx:t}};return t[11]!==void 0&&(u.dragging=t[11]),e=new Ht({props:u}),R.push(()=>X(e,"dragging",i)),e.$on("load",t[22]),{c(){T(e.$$.fragment)},m(r,o){B(e,r,o),s=!0},p(r,o){const l={};o[0]&1&&(l.disable_click=!!r[0]),o[0]&4191975|o[1]&134217728&&(l.$$scope={dirty:o,ctx:r}),!n&&o[0]&2048&&(n=!0,l.dragging=r[11],V(()=>n=!1)),e.$set(l)},i(r){s||(p(e.$$.fragment,r),s=!0)},o(r){A(e.$$.fragment,r),s=!1},d(r){S(e,r)}}}function at(t){let e,n,s,i;return{c(){e=q("img"),d(e,"class","absolute-img svelte-rlgzoo"),Y(e.src,n=t[20]||t[0]?.image||t[0])||d(e,"src",n),d(e,"alt",""),N(e,"webcam",t[5]==="webcam"&&t[9])},m(u,r){C(u,e,r),t[50](e),s||(i=P(e,"load",t[25]),s=!0)},p(u,r){r[0]&1048577&&!Y(e.src,n=u[20]||u[0]?.image||u[0])&&d(e,"src",n),r[0]&544&&N(e,"webcam",u[5]==="webcam"&&u[9])},d(u){u&&v(e),t[50](null),s=!1,i()}}}function ft(t){let e,n,s,i,u,r,o,l;function h(_){t[52](_)}function f(_){t[53](_)}let g={value:t[0],mode:t[12],width:t[15]||t[19],height:t[14]||t[18],container_height:t[16]||t[18],value_img:t[17],source:t[5]};t[2]!==void 0&&(g.brush_radius=t[2]),t[21]!==void 0&&(g.brush_color=t[21]),e=new Qe({props:g}),t[51](e),R.push(()=>X(e,"brush_radius",h)),R.push(()=>X(e,"brush_color",f)),e.$on("change",t[24]),u=new Ge({}
1),u.$on("undo",t[54]),u.$on("clear",t[26]);let a=(t[1]==="color-sketch"||t[1]==="sketch")&&_t(t);return{c(){T(e.$$.fragment),i=U(),T(u.$$.fragment),r=U(),a&&a.c(),o=oe()},m(_,b){B(e,_,b),C(_,i,b),B(u,_,b),C(_,r,b),a&&a.m(_,b),C(_,o,b),l=!0},p(_,b){const I={};b[0]&1&&(I.value=_[0]),b[0]&4096&&(I.mode=_[12]),b[0]&557056&&(I.width=_[15]||_[19]),b[0]&278528&&(I.height=_[14]||_[18]),b[0]&327680&&(I.container_height=_[16]||_[18]),b[0]&131072&&(I.value_img=_[17]),b[0]&32&&(I.source=_[5]),!n&&b[0]&4&&(n=!0,I.brush_radius=_[2],V(()=>n=!1)),!s&&b[0]&2097152&&(s=!0,I.brush_color=_[21],V(()=>s=!1)),e.$set(I),_[1]==="color-sketch"||_[1]==="sketch"?a?(a.p(_,b),b[0]&2&&p(a,1)):(a=_t(_),a.c(),p(a,1),a.m(o.parentNode,o)):a&&(Z(),A(a,1,1,()=>{a=null}),K())},i(_){l||(p(e.$$.fragment,_),p(u.$$.fragment,_),p(a),l=!0)},o(_){A(e.$$.fragment,_),A(u.$$.fragment,_),A(a),l=!1},d(_){t[51](null),S(e,_),_&&v(i),S(u,_),_&&v(r),a&&a.d(_),_&&v(o)}}}function _t(t){let e,n,s,i;function u(l){t[55](l)}function r(l){t[56](l)}let o={container_height:t[16]||t[18],img_width:t[15]||t[19],img_height:t[14]||t[18],mode:t[12]};return t[2]!==void 0&&(o.brush_radius=t[2]),t[21]!==void 0&&(o.brush_color=t[21]),e=new Ze({props:o}),R.push(()=>X(e,"brush_radius",u)),R.push(()=>X(e,"brush_color",r)),{c(){T(e.$$.fragment)},m(l,h){B(e,l,h),i=!0},p(l,h){const f={};h[0]&327680&&(f.container_height=l[16]||l[18]),h[0]&557056&&(f.img_width=l[15]||l[19]),h[0]&278528&&(f.img_height=l[14]||l[18]),h[0]&4096&&(f.mode=l[12]),!n&&h[0]&4&&(n=!0,f.brush_radius=l[2],V(()=>n=!1)),!s&&h[0]&2097152&&(s=!0,f.brush_color=l[21],V(()=>s=!1)),e.$set(f)},i(l){i||(p(e.$$.fragment,l),i=!0)},o(l){A(e.$$.fragment,l),i=!1},d(l){S(e,l)}}}function ht(t){let e,n;return e=new Wt({props:{streaming:t[7],pending:t[8],mirror_webcam:t[9]}}),e.$on("capture",t[45]),e.$on("stream",t[24]),e.$on("error",t[46]),{c(){T(e.$$.fragment)},m(s,i){B(e,s,i),n=!0},p(s,i){const u={};i[0]&128&&(u.streaming=s[7]),i[0]&256&&(u.pending=s[8]),i[0]&512&&(u.mirror_webcam=s[9]),e.$set(u)},i(s){n||(p(e.$$.fragment,s),n=!0)},o(s){A(e.$$.fragment,s),n=!1},d(s){S(e,s)}}}function ct(t){let e,n,s,i;function u(l){t[40](l)}function r(l){t[41](l)}let o={container_height:t[16]||t[18],img_width:t[15]||t[19],img_height:t[14]||t[18]};return t[2]!==void 0&&(o.brush_radius=t[2]),t[21]!==void 0&&(o.brush_color=t[21]),e=new Ze({props:o}),R.push(()=>X(e,"brush_radius",u)),R.push(()=>X(e,"brush_color",r)),{c(){T(e.$$.fragment)},m(l,h){B(e,l,h),i=!0},p(l,h){const f={};h[0]&327680&&(f.container_height=l[16]||l[18]),h[0]&557056&&(f.img_width=l[15]||l[19]),h[0]&278528&&(f.img_height=l[14]||l[18]),!n&&h[0]&4&&(n=!0,f.brush_radius=l[2],V(()=>n=!1)),!s&&h[0]&2097152&&(s=!0,f.brush_color=l[21],V(()=>s=!1)),e.$set(f)},i(l){i||(p(e.$$.fragment,l),i=!0)},o(l){A(e.$$.fragment,l),i=!1},d(l){S(e,l)}}}function dn(t){let e,n;return{c(){e=q("img"),Y(e.src,n=t[0].image||t[0])||d(e,"src",n),d(e,"alt","hello"),d(e,"class","svelte-rlgzoo"),N(e,"webcam",t[5]==="webcam"&&t[9])},m(s,i){C(s,e,i)},p(s,i){i[0]&1&&!Y(e.src,n=s[0].image||s[0])&&d(e,"src",n),i[0]&544&&N(e,"webcam",s[5]==="webcam"&&s[9])},i:W,o:W,d(s){s&&v(e)}}}function bn(t){let e=t[20],n,s,i,u=mt(t),r=t[15]>0&>(t);return{c(){u.c(),n=U(),r&&r.c(),s=oe()},m(o,l){u.m(o,l),C(o,n,l),r&&r.m(o,l),C(o,s,l),i=!0},p(o,l){l[0]&1048576&&G(e,e=o[20])?(u.d(1),u=mt(o),u.c(),u.m(n.parentNode,n)):u.p(o,l),o[15]>0?r?(r.p(o,l),l[0]&32768&&p(r,1)):(r=gt(o),r.c(),p(r,1),r.m(s.parentNode,s)):r&&(Z(),A(r,1,1,()=>{r=null}),K())},i(o){i||(p(r),i=!0)},o(o){A(r),i=!1},d(o){u.d(o),o&&v(n),r&&r.d(o),o&&v(s)}}}function kn(t){let e,n,s,i,u;return e=new qe({props:{editable:!0}}),e.$on("edit",t[30]),e.$on("clear",t[23]),{c(){T(e.$$.fragment),n=U(),s=q("img"),Y(s.src,i=t[0])||d(s,"src",i),d(s,"alt",""),d(s,"class","svelte-rlgzoo"),N(s,"scale-x-[-1]",t[5]==="webcam"&&t[9])},m(r,o){B(e,r,o),C(r,n,o),C(r,s,o),u=!0},p(r,o){(!u||o[0]&1&&!Y(s.src,i=r[0]))&&d(s,"src",i),o[0]&544&&N(s,"scale-x-[-1]",r[5]==="webcam"&&r[9])},i(r){u||(p(e.$$.fragment,r),u=!0)},o(r){A(e.$$.fragment,r),u=!1},d(r){S(e,r),r&&v(n),r&&v(s)}}}function pn(t){let e,n,s,i,u={image:t[0]};return e=new At({props:u}),t[28](e),e.$on("crop",t[24]),s=new qe({}),s.$on("clear",t[29]),{c(){T(e.$$.fragment),n=U(),T(s.$$.fragment)},m(r,o){B(e,r,o),C(r,n,o),B(s,r,o),i=!0},p(r,o){const l={};o[0]&1&&(l.image=r[0]),e.$set(l)}
1,i(r){i||(p(e.$$.fragment,r),p(s.$$.fragment,r),i=!0)},o(r){A(e.$$.fragment,r),A(s.$$.fragment,r),i=!1},d(r){t[28](null),S(e,r),r&&v(n),S(s,r)}}}function wn(t){let e;const n=t[27].default,s=Tt(n,t,t[58],null);return{c(){s&&s.c()},m(i,u){s&&s.m(i,u),e=!0},p(i,u){s&&s.p&&(!e||u[1]&134217728)&&Bt(s,n,i,i[58],e?Dt(n,i[58],u,null):St(i[58]),null)},i(i){e||(p(s,i),e=!0)},o(i){A(s,i),e=!1},d(i){s&&s.d(i)}}}function mt(t){let e,n,s,i;return{c(){e=q("img"),d(e,"class","absolute-img svelte-rlgzoo"),Y(e.src,n=t[20]||t[0]?.image||t[0])||d(e,"src",n),d(e,"alt",""),N(e,"webcam",t[5]==="webcam"&&t[9])},m(u,r){C(u,e,r),t[31](e),s||(i=P(e,"load",t[25]),s=!0)},p(u,r){r[0]&1048577&&!Y(e.src,n=u[20]||u[0]?.image||u[0])&&d(e,"src",n),r[0]&544&&N(e,"webcam",u[5]==="webcam"&&u[9])},d(u){u&&v(e),t[31](null),s=!1,i()}}}function gt(t){let e,n,s,i,u,r,o,l;function h(_){t[33](_)}function f(_){t[34](_)}let g={value:t[0],mode:t[12],width:t[15]||t[19],height:t[14]||t[18],container_height:t[16]||t[18],value_img:t[17],source:t[5],shape:t[6]};t[2]!==void 0&&(g.brush_radius=t[2]),t[21]!==void 0&&(g.brush_color=t[21]),e=new Qe({props:g}),t[32](e),R.push(()=>X(e,"brush_radius",h)),R.push(()=>X(e,"brush_color",f)),e.$on("change",t[24]),u=new Ge({}),u.$on("undo",t[35]),u.$on("clear",t[26]);let a=(t[1]==="color-sketch"||t[1]==="sketch")&&dt(t);return{c(){T(e.$$.fragment),i=U(),T(u.$$.fragment),r=U(),a&&a.c(),o=oe()},m(_,b){B(e,_,b),C(_,i,b),B(u,_,b),C(_,r,b),a&&a.m(_,b),C(_,o,b),l=!0},p(_,b){const I={};b[0]&1&&(I.value=_[0]),b[0]&4096&&(I.mode=_[12]),b[0]&557056&&(I.width=_[15]||_[19]),b[0]&278528&&(I.height=_[14]||_[18]),b[0]&327680&&(I.container_height=_[16]||_[18]),b[0]&131072&&(I.value_img=_[17]),b[0]&32&&(I.source=_[5]),b[0]&64&&(I.shape=_[6]),!n&&b[0]&4&&(n=!0,I.brush_radius=_[2],V(()=>n=!1)),!s&&b[0]&2097152&&(s=!0,I.brush_color=_[21],V(()=>s=!1)),e.$set(I),_[1]==="color-sketch"||_[1]==="sketch"?a?(a.p(_,b),b[0]&2&&p(a,1)):(a=dt(_),a.c(),p(a,1),a.m(o.parentNode,o)):a&&(Z(),A(a,1,1,()=>{a=null}),K())},i(_){l||(p(e.$$.fragment,_),p(u.$$.fragment,_),p(a),l=!0)},o(_){A(e.$$.fragment,_),A(u.$$.fragment,_),A(a),l=!1},d(_){t[32](null),S(e,_),_&&v(i),S(u,_),_&&v(r),a&&a.d(_),_&&v(o)}}}function dt(t){let e,n,s,i;function u(l){t[36](l)}function r(l){t[37](l)}let o={container_height:t[16]||t[18],img_width:t[15]||t[19],img_height:t[14]||t[18],mode:t[12]};return t[2]!==void 0&&(o.brush_radius=t[2]),t[21]!==void 0&&(o.brush_color=t[21]),e=new Ze({props:o}),R.push(()=>X(e,"brush_radius",u)),R.push(()=>X(e,"brush_color",r)),{c(){T(e.$$.fragment)},m(l,h){B(e,l,h),i=!0},p(l,h){const f={};h[0]&327680&&(f.container_height=l[16]||l[18]),h[0]&557056&&(f.img_width=l[15]||l[19]),h[0]&278528&&(f.img_height=l[14]||l[18]),h[0]&4096&&(f.mode=l[12]),!n&&h[0]&4&&(n=!0,f.brush_radius=l[2],V(()=>n=!1)),!s&&h[0]&2097152&&(s=!0,f.brush_color=l[21],V(()=>s=!1)),e.$set(f)},i(l){i||(p(e.$$.fragment,l),i=!0)},o(l){A(e.$$.fragment,l),i=!1},d(l){S(e,l)}}}function An(t){let e,n,s,i;const u=[wn,pn,kn,bn,dn],r=[];function o(l,h){return l[0]===null&&!l[20]||l[7]?0:l[1]==="select"?1:l[1]==="editor"?2:(l[1]==="sketch"||l[1]==="color-sketch")&&(l[0]!==null||l[20])?3:4}return e=o(t),n=r[e]=u[e](t),{c(){n.c(),s=oe()},m(l,h){r[e].m(l,h),C(l,s,h),i=!0},p(l,h){let f=e;e=o(l),e===f?r[e].p(l,h):(Z(),A(r[f],1,1,()=>{r[f]=null}),K(),n=r[e],n?n.p(l,h):(n=r[e]=u[e](l),n.c()),p(n,1),n.m(s.parentNode,s))},i(l){i||(p(n),i=!0)},o(l){A(n),i=!1},d(l){r[e].d(l),l&&v(s)}}}function In(t){let e,n,s,i,u,r,o;e=new wt({props:{show_label:t[4],Icon:t[5]==="canvas"?xe:Ue,label:t[3]||(t[5]==="canvas"?"Sketch":"Image")}});const l=[gn,mn,cn,hn,_n,fn,an],h=[];function f(g,a){return g[5]==="upload"?0:g[5]==="canvas"?1:g[0]===null&&!g[20]||g[7]?2:g[1]==="select"?3:g[1]==="editor"?4:(g[1]==="sketch"||g[1]==="color-sketch")&&(g[0]!==null||g[20])?5:6}return i=f(t),u=h[i]=l[i](t),{c(){T(e.$$.fragment),n=U(),s=q("div"),u.c(),d(s,"data-testid","image"),d(s,"class","svelte-rlgzoo"),Xe(()=>t[57].call(s)),N(s,"fixed-height",t[5]!=="webcam"||t[1]==="sketch"||t[1]==="color-sketch")},m(g,a){B(e,g,a),C(g,n,a),C(g,s,a),h[i].m(s,null),r=kt(s,t[57].bind(s)),o=!0},p(g,a){const _={};a[0]&16&&(_.show_label=g[4]),a[0]&32&&(_.Icon=g[5]==="canvas"?xe:Ue),a[0]&40&&(_.label=g[3]||(g[5]==="canvas"?"Sketch":"Image")),e.$set(_);let b=i;i=f(g),i===b?h[i].p(g,a):(Z(),A(h[b],1,1,()=>{h[b]=null}),K(),u=h[i],u?u.p(g,a):(u=h[i]=l[i](g),u.c()),p(u,1),u.m(s,null)),a[0]&34&&N(s,"fixed-height",g[5]!=="webcam"||g[1]==="sketch"||g[1]==="color-sketch")},i(g){o||(p(e.$$.fragment,g),p(u),o=!0)},o(g){A(e.$$.fragment,g),A(u),o=!1},d(g){S(e,g),g&&v(n),g&&v(s),h[i].d(),r()}}}
1function yn(t,e,n){let s,{$$slots:i={},$$scope:u}=e,{value:r}=e,{label:o=void 0}=e,{show_label:l}=e,{source:h="upload"}=e,{tool:f="editor"}=e,{shape:g}=e,{streaming:a=!1}=e,{pending:_=!1}=e,{mirror_webcam:b}=e,{brush_radius:I}=e,M,j;r&&(h==="upload"||h==="webcam")&&f==="sketch"&&(r={image:r,mask:null});function te({detail:c}){f==="color-sketch"?n(20,$=c):n(0,r=(h==="upload"||h==="webcam")&&f==="sketch"?{image:c,mask:null}:c),k("upload",c)}function ae({detail:c}){n(0,r=null),n(20,$=void 0),k("clear")}async function E({detail:c},z){D==="mask"?h==="webcam"&&z?n(0,r={image:c,mask:null}):n(0,r={image:typeof r=="string"?r:r?.image||null,mask:c}):(h==="upload"||h==="webcam")&&f==="sketch"?n(0,r={image:c,mask:null}):n(0,r=c),await ge(),k(a?"stream":"edit")}const k=me();let F=!1;function O(c){const z=c.currentTarget;n(15,se=z.naturalWidth),n(14,ne=z.naturalHeight),n(16,re=z.getBoundingClientRect().height)}async function ie(){M.clear(),await ge(),n(0,r=null),n(20,$=void 0)}let ne=0,se=0,re=0,D,w,fe,le,$;pt(async()=>{f==="color-sketch"&&r&&typeof r=="string"&&(n(20,$=r),await ge(),O({currentTarget:w}))});function we(c){R[c?"unshift":"push"](()=>{j=c,n(10,j),n(0,r)})}const Ne=c=>(ae(c),n(1,f="editor")),de=()=>n(1,f="select");function Fe(c){R[c?"unshift":"push"](()=>{w=c,n(17,w)})}function Ae(c){R[c?"unshift":"push"](()=>{M=c,n(13,M)})}function We(c){I=c,n(2,I)}function Ie(c){s=c,n(21,s),n(12,D),n(5,h),n(1,f)}const ye=()=>M.undo();function Ce(c){I=c,n(2,I)}function ve(c){s=c,n(21,s),n(12,D),n(5,h),n(1,f)}function ze(c){F=c,n(11,F)}const _e=()=>M.undo();function Me(c){I=c,n(2,I)}function Te(c){s=c,n(21,s),n(12,D),n(5,h),n(1,f)}function Be(c){I=c,n(2,I)}function Se(c){s=c,n(21,s),n(12,D),n(5,h),n(1,f)}function De(c){R[c?"unshift":"push"](()=>{M=c,n(13,M)})}const Ee=c=>f==="color-sketch"?te(c):E(c,!0);function ue(c){ce.call(this,t,c)}function he(c){R[c?"unshift":"push"](()=>{j=c,n(10,j),n(0,r)})}const Re=c=>(ae(c),n(1,f="editor")),be=()=>n(1,f="select");function Oe(c){R[c?"unshift":"push"](()=>{w=c,n(17,w)})}function je(c){R[c?"unshift":"push"](()=>{M=c,n(13,M)})}function He(c){I=c,n(2,I)}function Ye(c){s=c,n(21,s),n(12,D),n(5,h),n(1,f)}const Je=()=>M.undo();function Pe(c){I=c,n(2,I)}function m(c){s=c,n(21,s),n(12,D),n(5,h),n(1,f)}function y(){fe=this.offsetHeight,le=this.offsetWidth,n(18,fe),n(19,le)}return t.$$set=c=>{"value"in c&&n(0,r=c.value),"label"in c&&n(3,o=c.label),"show_label"in c&&n(4,l=c.show_label),"source"in c&&n(5,h=c.source),"tool"in c&&n(1,f=c.tool),"shape"in c&&n(6,g=c.shape),"streaming"in c&&n(7,a=c.streaming),"pending"in c&&n(8,_=c.pending),"mirror_webcam"in c&&n(9,b=c.mirror_webcam),"brush_radius"in c&&n(2,I=c.brush_radius),"$$scope"in c&&n(58,u=c.$$scope)},t.$$.update=()=>{t.$$.dirty[0]&1&&k("change",r),t.$$.dirty[0]&2048&&k("drag",F),t.$$.dirty[0]&34&&(h==="canvas"&&f==="sketch"?n(12,D="bw-sketch"):f==="color-sketch"?n(12,D="color-sketch"):(h==="upload"||h==="webcam")&&f==="sketch"?n(12,D="mask"):n(12,D="editor")),t.$$.dirty[0]&4096&&n(21,s=D=="mask"?"#000000":"#000"),t.$$.dirty[0]&1&&(r===null||r.image===null&&r.mask===null)&&n(20,$=void 0),t.$$.dirty[0]&1025&&j&&(r?(n(10,j.image=r,j),j.create()):j.destroy())},[r,f,I,o,l,h,g,a,_,b,j,F,D,M,ne,se,re,w,fe,le,$,s,te,ae,E,O,ie,i,we,Ne,de,Fe,Ae,We,Ie,ye,Ce,ve,ze,_e,Me,Te,Be,Se,De,Ee,ue,he,Re,be,Oe,je,He,Ye,Je,Pe,m,y,u]}class Cn extends x{constructor(e){super(),ee(this,e,yn,In,G,{value:0,label:3,show_label:4,source:5,tool:1,shape:6,streaming:7,pending:8,mirror_webcam:9,brush_radius:2},null,[-1,-1])}}function vn(t){let e,n,s,i,u,r,o;return s=new pe({props:{Icon:Jt,label:"Download"}}),{c(){e=q("div"),n=q("a"),T(s.$$.fragment),i=U(),u=q("img"),d(n,"href",t[0]),d(n,"target",window.__is_colab__?"_blank":null),d(n,"download","image"),d(e,"class","download svelte-kt1jzh"),Y(u.src,r=t[0])||d(u,"src",r),d(u,"alt",""),d(u,"class","svelte-kt1jzh")},m(l,h){C(l,e,h),H(e,n),B(s,n,null),C(l,i,h),C(l,u,h),o=!0},p(l,h){(!o||h&1)&&d(n,"href",l[0]),(!o||h&1&&!Y(u.src,r=l[0]))&&d(u,"src",r)},i(l){o||(p(s.$$.fragment,l),o=!0)},o(l){A(s.$$.fragment,l),o=!1},d(l){l&&v(e),S(s),l&&v(i),l&&v(u)}}}function zn(t){let e,n;return e=new Yt({props:{size:"large",unpadded_box:!0,$$slots:{default:[Mn]},$$scope:{ctx:t}}}),{c(){T(e.$$.fragment)},m(s,i){B(e,s,i),n=!0},p(s,i){const u={};i&16&&(u.$$scope={dirty:i,ctx:s}),e.$set(u)},i(s){n||(p(e.$$.fragment,s),n=!0)},o(s){A(e.$$.fragment,s),n=!1},d(s){S(e,s)}}}function Mn(t){let e,n;return e=new Ue({}),{c(){T(e.$$.fragment)},m(s,i){B(e,s,i),n=!0},i(s){n||(p(e.$$.fragment,s),n=!0)},o(s){A(e.$$.fragment,s),n=!1},d(s){S(e,s)}}}function Tn(t){let e,n,s,i,u,r;e=new wt({props:{show_label:t[2],Icon:Ue,label:t[1]||"Image"}});const o=[zn,vn],l=[];function h(f,g){return f[0]===null?0:1}return s=h(t),i=l[s]=o[s](t),{c(){T(e.$$.fragment),n=U(),i.c(),u=oe()},m(f,g){B(e,f,g),C(f,n,g),l[s].m(f,g),C(f,u,g),r=!0},p(f,[g]){const a={};
1g&4&&(a.show_label=f[2]),g&2&&(a.label=f[1]||"Image"),e.$set(a);let _=s;s=h(f),s===_?l[s].p(f,g):(Z(),A(l[_],1,1,()=>{l[_]=null}),K(),i=l[s],i?i.p(f,g):(i=l[s]=o[s](f),i.c()),p(i,1),i.m(u.parentNode,u))},i(f){r||(p(e.$$.fragment,f),p(i),r=!0)},o(f){A(e.$$.fragment,f),A(i),r=!1},d(f){S(e,f),f&&v(n),l[s].d(f),f&&v(u)}}}function Bn(t,e,n){let{value:s}=e,{label:i=void 0}=e,{show_label:u}=e;const r=me();return t.$$set=o=>{"value"in o&&n(0,s=o.value),"label"in o&&n(1,i=o.label),"show_label"in o&&n(2,u=o.show_label)},t.$$.update=()=>{t.$$.dirty&1&&s&&r("change",s)},[s,i,u]}class Sn extends x{constructor(e){super(),ee(this,e,Bn,Tn,G,{value:0,label:1,show_label:2})}}function Dn(t){let e,n,s;function i(r){t[17](r)}let u={brush_radius:t[14],shape:t[13],source:t[5],tool:t[6],label:t[7],show_label:t[8],pending:t[10],streaming:t[9],mirror_webcam:t[12],$$slots:{default:[Rn]},$$scope:{ctx:t}};return t[0]!==void 0&&(u.value=t[0]),e=new Cn({props:u}),R.push(()=>X(e,"value",i)),e.$on("edit",t[18]),e.$on("clear",t[19]),e.$on("change",t[20]),e.$on("stream",t[21]),e.$on("drag",t[22]),e.$on("upload",t[23]),e.$on("error",t[24]),{c(){T(e.$$.fragment)},m(r,o){B(e,r,o),s=!0},p(r,o){const l={};o&16384&&(l.brush_radius=r[14]),o&8192&&(l.shape=r[13]),o&32&&(l.source=r[5]),o&64&&(l.tool=r[6]),o&128&&(l.label=r[7]
1),o&256&&(l.show_label=r[8]),o&1024&&(l.pending=r[10]),o&512&&(l.streaming=r[9]),o&4096&&(l.mirror_webcam=r[12]),o&67108864&&(l.$$scope={dirty:o,ctx:r}),!n&&o&1&&(n=!0,l.value=r[0],V(()=>n=!1)),e.$set(l)},i(r){s||(p(e.$$.fragment,r),s=!0)},o(r){A(e.$$.fragment,r),s=!1},d(r){S(e,r)}}}function En(t){let e,n;return e=new Sn({props:{value:t[0],label:t[7],show_label:t[8]}}),{c(){T(e.$$.fragment)},m(s,i){B(e,s,i),n=!0},p(s,i){const u={};i&1&&(u.value=s[0]),i&128&&(u.label=s[7]),i&256&&(u.show_label=s[8]),e.$set(u)},i(s){n||(p(e.$$.fragment,s),n=!0)},o(s){A(e.$$.fragment,s),n=!1},d(s){S(e,s)}}}function Rn(t){let e,n;return e=new Pt({props:{type:"image"}}),{c(){T(e.$$.fragment)},m(s,i){B(e,s,i),n=!0},p:W,i(s){n||(p(e.$$.fragment,s),n=!0)},o(s){A(e.$$.fragment,s),n=!1},d(s){S(e,s)}}}function jn(t){let e,n,s,i,u,r;const o=[t[1]];let l={};for(let a=0;a<o.length;a+=1)l=Et(l,o[a]);e=new Rt({props:l});const h=[En,Dn],f=[];function g(a,_){return a[15]==="static"?0:1}return s=g(t),i=f[s]=h[s](t),{c(){T(e.$$.fragment),n=U(),i.c(),u=oe()},m(a,_){B(e,a,_),C(a,n,_),f[s].m(a,_),C(a,u,_),r=!0},p(a,_){const b=_&2?jt(o,[Lt(a[1])]):{};e.$set(b);let I=s;s=g(a),s===I?f[s].p(a,_):(Z(),A(f[I],1,1,()=>{f[I]=null}),K(),i=f[s],i?i.p(a,_):(i=f[s]=h[s](a),i.c()),p(i,1),i.m(u.parentNode,u))},i(a){r||(p(e.$$.fragment,a),p(i),r=!0)},o(a){A(e.$$.fragment,a),A(i),r=!1},d(a){S(e,a),a&&v(n),f[s].d(a),a&&v(u)}}}function Ln(t){let e,n;return e=new Ut({props:{visible:t[4],variant:t[15]==="dynamic"&&t[0]===null&&t[5]==="upload"?"dashed":"solid",border_mode:t[16]?"focus":"base",padding:!1,elem_id:t[2],elem_classes:t[3],style:{height:t[11].height,width:t[11].width},allow_overflow:!1,$$slots:{default:[jn]},$$scope:{ctx:t}}}),{c(){T(e.$$.fragment)},m(s,i){B(e,s,i),n=!0},p(s,[i]){const u={};i&16&&(u.visible=s[4]),i&32801&&(u.variant=s[15]==="dynamic"&&s[0]===null&&s[5]==="upload"?"dashed":"solid"),i&65536&&(u.border_mode=s[16]?"focus":"base"),i&4&&(u.elem_id=s[2]),i&8&&(u.elem_classes=s[3]),i&2048&&(u.style={height:s[11].height,width:s[11].width}),i&67237859&&(u.$$scope={dirty:i,ctx:s}),e.$set(u)},i(s){n||(p(e.$$.fragment,s),n=!0)},o(s){A(e.$$.fragment,s),n=!1},d(s){S(e,s)}}}function Un(t,e,n){let{elem_id:s=""}=e,{elem_classes:i=[]}=e,{visible:u=!0}=e,{value:r=null}=e,{source:o="upload"}=e,{tool:l="editor"}=e,{label:h}=e,{show_label:f}=e,{streaming:g}=e,{pending:a}=e,{style:_={}}=e,{mirror_webcam:b}=e,{shape:I}=e,{brush_radius:M}=e,{loading_status:j}=e,{mode:te}=e;const ae=me();let E;function k(w){r=w,n(0,r)}function F(w){ce.call(this,t,w)}function O(w){ce.call(this,t,w)}function ie(w){ce.call(this,t,w)}function ne(w){ce.call(this,t,w)}const se=({detail:w})=>n(16,E=w);function re(w){ce.call(this,t,w)}const D=({detail:w})=>{n(1,j=j||{}),n(1,j.status="error",j),n(1,j.message=w,j)};return t.$$set=w=>{"elem_id"in w&&n(2,s=w.elem_id),"elem_classes"in w&&n(3,i=w.elem_classes),"visible"in w&&n(4,u=w.visible),"value"in w&&n(0,r=w.value),"source"in w&&n(5,o=w.source),"tool"in w&&n(6,l=w.tool),"label"in w&&n(7,h=w.label),"show_label"in w&&n(8,f=w.show_label),"streaming"in w&&n(9,g=w.streaming),"pending"in w&&n(10,a=w.pending),"style"in w&&n(11,_=w.style),"mirror_webcam"in w&&n(12,b=w.mirror_webcam),"shape"in w&&n(13,I=w.shape),"brush_radius"in w&&n(14,M=w.brush_radius),"loading_status"in w&&n(1,j=w.loading_status),"mode"in w&&n(15,te=w.mode)},t.$$.update=()=>{t.$$.dirty&1&&n(0,r=r||null),t.$$.dirty&1&&ae("change")},[r,j,s,i,u,o,l,h,f,g,a,_,b,I,M,te,E,k,F,O,ie,ne,se,re,D]}class qn extends x{constructor(e){super(),ee(this,e,Un,Ln,G,{elem_id:2,elem_classes:3,visible:4,value:0,source:5,tool:6,label:7,show_label:8,streaming:9,pending:10,style:11,mirror_webcam:12,shape:13,brush_radius:14,loading_status:1,mode:15})}}var Kn=qn;const $n=["static","dynamic"],xn=t=>({type:{payload:"string"},description:{payload:"image data as base64 string"},example_data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg=="});export{Kn as Component,ns as ExampleComponent,xn as document,$n as modes}; 2//# sourceMappingURL=index.c4a41da9.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.