1import{c as Ee,j as e,u as an,r as s,T as Ge,I as Xe,B as b,C as rn,o as A,aR as Un,aS as _n,Q as oe,p as je,S as le,P as xn,af as Vn,s as Be,g as Pn,ab as Xn,ac as Yn,ad as Gn,K as Ye,aT as Kn,aU as qn,d as Zn,e as Qn,h as $n,aV as Jn,f as et,q as dn,F as Fe,t as Oe,v as Te,M as y,G as en,D as nt,E as mn,H as un,aW as tt,L as st,N as it,O as xe,ae as rt,aX as at,R as ot,aO as lt,W as ct}from"./index-DVqSLbvA.js";import{M as dt}from"./MoreVert-CXq0kdHj.js";import{E as nn}from"./Edit-CO4lHsYn.js";import{S as tn}from"./Search-juqc_gZM.js";import{u as mt,C as Sn,P as ut}from"./useInfiniteScroll-DiE35etQ.js";import{A as ht}from"./Archive-C4ilIT6z.js";import{Z as xt}from"./ZoomIn-BFVI75I_.js";import{V as gn}from"./Visibility-Bd2HB3Fx.js";import{S as gt}from"./SwapHoriz-BvJ7mVKA.js";import{a as vt,b as ft,c as pt,d as jt,u as bt,e as yt,f as St,g as Ct,h as Mt,i as wt,j as It,k as kt,l as At,m as Et,n as Pt}from"./useEnvironments-D3t20l2b.js";import{D as zn,a as zt,b as Lt,c as Dt,C as sn}from"./ConfirmDialog-BkZXhep4.js";import{u as Rt}from"./useAdminDashboard-BUZ-DQxj.js";import{C as Ht,I as Ft}from"./ImageDropzone-Bp63mFwG.js";import{O as Ot,F as Tt,a as Bt}from"./OpenWith-BoEsf7Ti.js";import{T as Cn,a as ge}from"./ToggleButtonGroup-CPXnfrfR.js";import{C as Nt}from"./CardMedia-DQvoy8Am.js";import"./LastPage-Brw78WUI.js";import"./index-CntsEA-C.js";import"./index-BTVi1biC.js";const Wt=Ee(e.jsx("path",{d:"M18 20H4V6h9V4H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-9h-2zm-7.79-3.17-1.96-2.36L5.5 18h11l-3.54-4.71zM20 4V1h-2v3h-3c.01.01 0 2 0 2h3v2.99c.01.01 2 0 2 0V6h3V4z"}),"AddPhotoAlternateOutlined"),Ut=Ee(e.jsx("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m0 16H5v-4.58l.99.99 4-4 4 4 4-3.99L19 12.43zm0-9.41-1.01-1.01-4 4.01-4-4-4 4-.99-1V5h14z"}),"BrokenImageOutlined"),hn=Ee(e.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM8 9h8v10H8zm7.5-5-1-1h-5l-1 1H5v2h14V4z"}),"DeleteOutline"),_t=Ee(e.jsx("path",{d:"M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7zm2 16H5V5h11.17L19 7.83zm-7-7c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3M6 6h9v4H6z"}),"SaveOutlined"),Mn=Ee(e.jsx("path",{d:"M12 17.27 18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"}),"Star"),Vt=Ee(e.jsx("path",{d:"m22 9.24-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03zM12 15.4l-3.76 2.27 1-4.28-3.32-2.88 4.38-.38L12 6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28z"}),"StarBorder"),wn=Ee(e.jsx("path",{d:"M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7M2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2m4.31-.78 3.15 3.15.02-.16c0-1.66-1.34-3-3-3z"}),"VisibilityOff"),_={Active:"Active",Inactive:"Inactive"},$={BuiltIn:"BuiltIn",Custom:"Custom"},ae={NameAsc:"NameAsc",NameDesc:"NameDesc",CreatedAtDesc:"CreatedAtDesc",CreatedAtAsc:"CreatedAtAsc"};function Xt(n){switch(n){case _.Active:return"success";case _.Inactive:return"default";default:return"default"}}const Yt=8,Gt=300;function Kt({onSelect:n,onCancel:j}){const{t:u}=an(),[i,h]=s.useState(""),[M,v]=s.useState("");s.useEffect(()=>{const l=setTimeout(()=>v(i),Gt);return()=>clearTimeout(l)},[i]);const{data:g,isLoading:H}=Rt({page:1,pageSize:Yt,search:M,sortColumn:"Name",sortDescending:!1}),T=g?.items??[];return e.jsxs(zn,{open:!0,onClose:j,maxWidth:"sm",fullWidth:!0,slotProps:{paper:{sx:{borderRadius:2}}},children:[e.jsx(zt,{sx:{pb:1,fontSize:"1.25rem",fontWeight:600},children:u("environments.assignTitle")}),e.jsxs(Lt,{sx:{pt:2},children:[e.jsx(Ge,{autoFocus:!0,fullWidth:!0,size:"small",value:i,onChange:l=>h(l.target.value),placeholder:u("environments.assignSearchPlaceholder"),sx:{mt:1},slotProps:{input:{startAdornment:e.jsx(Xe,{position:"start",children:e.jsx(tn,{fontSize:"small"})})}}}),H?e.jsx(b,{sx:{display:"flex",justifyContent:"center",py:4},children:e.jsx(rn,{size:28})}):T.length===0?e.jsx(A,{sx:{py:4,textAlign:"center"},color:"text.secondary",children:u("environments.assignNoAccounts")}):e.jsx(Un,{sx:{mt:1},children:T.map(l=>e.jsx(_n,{onClick:()=>n(l),disabled:l.status==="Suspended",sx:{borderRadius:1},children:e.jsx(oe,{primary:l.name,secondary:[l.countryCode,l.partnerName?u("environments.assignPartner",{name:l.partnerName}
1):null].filter(Boolean).join(" · ")})},l.id))})]}),e.jsx(Dt,{sx:{px:3,pb:3,pt:1},children:e.jsx(je,{onClick:j,size:"small",children:u("common.cancel")})})]})}const ve="#2196f3",fe="#ff9800",pe="#4caf50",qt={normal:{fillAlpha:.3,strokeAlpha:1,lineWidth:2,lineDash:[]},active:{fillAlpha:.25,strokeAlpha:1,lineWidth:3,lineDash:[]},context:{fillAlpha:.06,strokeAlpha:.5,lineWidth:1.5,lineDash:[6,4]}},In=10,Zt=16,Qt=8,$t=240;function Jt({imageUrl:n,frontalMask:j,sideMask:u,cornerMask:i,onMasksChange:h,onReplaceImage:M,onSave:v,saveDisabled:g=!1,isSaving:H=!1,readOnly:T=!1}){const{t:l}=an(),[O,V]=s.useState(null),[W,B]=s.useState(null),J=s.useRef(null),[F,ee]=s.useState("all"),[o,K]=s.useState("none"),[L,re]=s.useState(!1),[E,X]=s.useState(j??null),[I,ne]=s.useState(u??null),[S,te]=s.useState(i??null),[w,U]=s.useState("none"),[z,q]=s.useState(null),[D,Z]=s.useState(null),[Y,ce]=s.useState(null),[de,be]=s.useState(null),[me,Pe]=s.useState(null),[ze,C]=s.useState(!1),[x,se]=s.useState({width:0,height:0}),[c,Ke]=s.useState(1),[Le,Ne]=s.useState(null),[qe,We]=s.useState(null),we=s.useCallback(()=>o==="frontal"?E:o==="side"?I:o==="corner"?S:null,[o,E,I,S]),ie=ts(n);s.useEffect(()=>{if(Le===ie)return;let r=!1;const a=new Image;return a.onload=()=>{r||(J.current=a,se({width:a.naturalWidth,height:a.naturalHeight}),Ne(ie))},a.onerror=()=>{r||We(ie)},a.src=n,()=>{r=!0}},[n,ie,Le]);const ye=Le!==ie&&qe!==ie,Ue=qe===ie;s.useLayoutEffect(()=>{if(!O||x.width===0)return;const r=()=>{const d=O.clientWidth/x.width,m=L&&O.clientHeight>0?Math.min(d,O.clientHeight/x.height):d;Ke(m)};r();const a=new ResizeObserver(r);return a.observe(O),()=>a.disconnect()},[O,x,L]);const N=s.useCallback(r=>{const a=r.points.map(m=>m[0]),d=r.points.map(m=>m[1]);return{minX:Math.min(...a),maxX:Math.max(...a),minY:Math.min(...d),maxY:Math.max(...d)}},[]),G=s.useCallback((r,a)=>{if(!a||a.points.length!==4)return null;const d=N(a),m=Zt/c,f=Qt/c,{minX:p,maxX:P,minY:k,maxY:Ae}=d;return Math.abs(r[0]-p)<m&&Math.abs(r[1]-k)<m?"nw":Math.abs(r[0]-P)<m&&Math.abs(r[1]-k)<m?"ne":Math.abs(r[0]-P)<m&&Math.abs(r[1]-Ae)<m?"se":Math.abs(r[0]-p)<m&&Math.abs(r[1]-Ae)<m?"sw":Math.abs(r[1]-k)<f&&r[0]>p+m&&r[0]<P-m?"n":Math.abs(r[1]-Ae)<f&&r[0]>p+m&&r[0]<P-m?"s":Math.abs(r[0]-p)<f&&r[1]>k+m&&r[1]<Ae-m?"w":Math.abs(r[0]-P)<f&&r[1]>k+m&&r[1]<Ae-m?"e":null},[N,c]),De=s.useCallback((r,a)=>{if(!a||a.points.length!==4)return!1;const d=N(a);return r[0]>d.minX&&r[0]<d.maxX&&r[1]>d.minY&&r[1]<d.maxY},[N]),ue=x.width*c,Ie=x.height*c,Re=s.useCallback(()=>{const r=W?.getContext("2d"),a=J.current;if(!r||!a)return;r.clearRect(0,0,ue,Ie),r.drawImage(a,0,0,ue,Ie);const d=o==="frontal"||F==="frontal"||F==="all",m=o==="side"||F==="side"||F==="all",f=o==="corner"||F==="corner"||F==="all",p=[];d&&E?.points.length===4&&p.push({target:"frontal",mask:E,color:ve}),m&&I?.points.length===4&&p.push({target:"side",mask:I,color:fe}),f&&S?.points.length===4&&p.push({target:"corner",mask:S,color:pe});for(const k of p)k.target!==o&&kn(r,k.mask.points,k.color,c,o==="none"?"normal":"context");const P=p.find(k=>k.target===o);P&&(kn(r,P.mask.points,P.color,c,"active"),w!=="draw"&&es(r,P.mask.points,P.color,c,me)),w==="draw"&&D&&Y&&ns(r,D,Y,o==="frontal"?ve:o==="side"?fe:pe,c)},[W,ue,Ie,c,F,o,E,I,S,w,D,Y,me]);s.useLayoutEffect(()=>{Re()},[Re]);const He=s.useCallback(r=>{if(!W)return[0,0];const a=W.getBoundingClientRect(),d=Math.round((r.clientX-a.left)/c),m=Math.round((r.clientY-a.top)/c);return[Math.max(0,Math.min(d,x.width)),Math.max(0,Math.min(m,x.height))]},[W,c,x]),_e=s.useCallback((r,a,d)=>{const m=N(r);let{minX:f,maxX:p,minY:P,maxY:k}=m;switch(a){case"nw":f+=d[0],P+=d[1];break;case"n":P+=d[1];break;case"ne":p+=d[0],P+=d[1];break;case"e":p+=d[0];break;case"se":p+=d[0],k+=d[1];break;case"s":k+=d[1];break;case"sw":f+=d[0],k+=d[1];break;case"w":f+=d[0];break}return p-f<20&&(a?.includes("w")?f=p-20:p=f+20),k-P<20&&(a?.includes("n")||a==="n"?P=k-20:k=P+20),f=Math.max(0,f),P=Math.max(0,P),p=Math.min(x.width,p),k=Math.min(x.height,k),{points:[[f,P],[p,P],[p,k],[f,k]]}},[N,x]),Ze=s.useCallback((r,a)=>{const d=N(r);let m=a[0],f=a[1];return d.minX+m<0&&(m=-d.minX),d.maxX+m>x.width&&(m=x.width-d.maxX),d.minY+f<0&&(f=-d.minY),d.maxY+f>x.height&&(f=x.height-d.maxY),{points:r.points.map(p=>[p[0]+m,p[1]+f])}},[N,x]),Qe=s.useCallback(r=>
1{if(o==="none"||T)return;const a=He(r),d=we(),m=G(a,d);if(m){U("resize"),q(m),Z(a),be(d);return}if(De(a,d)){U("move"),Z(a),be(d);return}U("draw"),Z(a),ce(a)},[o,T,He,we,G,De]),Ve=s.useCallback(r=>{const a=He(r),d=we();if(o!=="none"&&w==="none"){const m=G(a,d);Pe(m),C(m===null&&De(a,d))}if(!(w==="none"||!D)){if(w==="draw")ce(a);else if(w==="resize"&&de&&z){const m=[a[0]-D[0],a[1]-D[1]],f=_e(de,z,m);o==="frontal"?X(f):o==="side"?ne(f):o==="corner"&&te(f)}else if(w==="move"&&de){const m=[a[0]-D[0],a[1]-D[1]],f=Ze(de,m);o==="frontal"?X(f):o==="side"?ne(f):o==="corner"&&te(f)}}},[o,w,D,de,z,He,we,G,De,_e,Ze]),he=s.useCallback(()=>{if(w==="draw"&&D&&Y){const r=Math.min(D[0],Y[0]),a=Math.max(D[0],Y[0]),d=Math.min(D[1],Y[1]),m=Math.max(D[1],Y[1]);if(a-r>10&&m-d>10){const p={points:[[r,d],[a,d],[a,m],[r,m]]};o==="frontal"?(X(p),h?.(p,I,S)):o==="side"?(ne(p),h?.(E,p,S)):o==="corner"&&(te(p),h?.(E,I,p))}}else(w==="resize"||w==="move")&&o!=="none"&&h?.(E,I,S);U("none"),q(null),Z(null),ce(null),be(null)},[w,D,Y,o,E,I,S,h]),Se=s.useCallback(()=>{w!=="none"&&he(),Pe(null),C(!1)},[w,he]),ke=r=>{r==="frontal"?(X(null),h?.(null,I,S)):r==="side"?(ne(null),h?.(E,null,S)):(te(null),h?.(E,I,null))},on=(r,a)=>{a&&(ee(a),K("none"))},Q=(r,a)=>{K(a??"none")},ln=()=>
1{if(o==="none"||T)return"default";if(w==="move"||w==="none"&&ze)return"move";if(w==="draw")return"crosshair";const r=w==="resize"?z:me;if(r)switch(r){case"nw":case"se":return"nwse-resize";case"ne":case"sw":return"nesw-resize";case"n":case"s":return"ns-resize";case"e":case"w":return"ew-resize"}return"crosshair"},$e=o!=="none",cn=we()!==null,Je=e.jsxs(e.Fragment,{children:[e.jsxs(le,{direction:"row",spacing:2,sx:{mb:2},flexWrap:"wrap",useFlexGap:!0,children:[e.jsxs(b,{children:[e.jsx(A,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:l("environment.display")}),e.jsxs(Cn,{value:F,exclusive:!0,onChange:on,size:"small",disabled:$e,children:[e.jsxs(ge,{value:"image",children:[e.jsx(gn,{sx:{mr:.5},fontSize:"small"}),l("environment.image")]}),e.jsxs(ge,{value:"frontal",children:[e.jsx(b,{sx:{width:12,height:12,bgcolor:ve,borderRadius:.5,mr:.5}}),l("environment.frontal")]}),e.jsxs(ge,{value:"side",children:[e.jsx(b,{sx:{width:12,height:12,bgcolor:fe,borderRadius:.5,mr:.5}}),l("environment.side")]}),e.jsxs(ge,{value:"corner",children:[e.jsx(b,{sx:{width:12,height:12,bgcolor:pe,borderRadius:.5,mr:.5}}),l("environment.corner")]}),e.jsx(ge,{value:"all",children:l("environment.all")})]})]}),!T&&e.jsxs(b,{children:[e.jsx(A,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:l("environment.editMask")}),e.jsxs(Cn,{value:o,exclusive:!0,onChange:Q,size:"small",children:[e.jsxs(ge,{value:"none",children:[e.jsx(gn,{sx:{mr:.5},fontSize:"small"}),l("environment.view")]}),e.jsxs(ge,{value:"frontal",children:[e.jsx(nn,{sx:{mr:.5},fontSize:"small"}),e.jsx(b,{sx:{width:12,height:12,bgcolor:ve,borderRadius:.5,mr:.5}}),l("environment.frontal")]}),e.jsxs(ge,{value:"side",children:[e.jsx(nn,{sx:{mr:.5},fontSize:"small"}),e.jsx(b,{sx:{width:12,height:12,bgcolor:fe,borderRadius:.5,mr:.5}}),l("environment.side")]}),e.jsxs(ge,{value:"corner",children:[e.jsx(nn,{sx:{mr:.5},fontSize:"small"}),e.jsx(b,{sx:{width:12,height:12,bgcolor:pe,borderRadius:.5,mr:.5}}),l("environment.corner")]})]})]}),!T&&e.jsxs(b,{sx:{ml:"auto",display:"flex",gap:1,alignItems:"flex-end",flexWrap:"wrap"},children:[M&&e.jsx(je,{size:"small",variant:"outlined",startIcon:e.jsx(Wt,{}),onClick:M,children:l("environment.replaceImage")}),e.jsx(je,{size:"small",variant:"outlined",color:"error",startIcon:e.jsx(hn,{}),onClick:()=>ke("frontal"),disabled:!E,children:l("environment.clearFrontal")}),e.jsx(je,{size:"small",variant:"outlined",color:"error",startIcon:e.jsx(hn,{}),onClick:()=>ke("side"),disabled:!I,children:l("environment.clearSide")}),e.jsx(je,{size:"small",variant:"outlined",color:"error",startIcon:e.jsx(hn,{}),onClick:()=>ke("corner"),disabled:!S,children:l("environment.clearCorner")})]})]}),$e&&e.jsx(xn,{sx:{p:1.5,mb:2,bgcolor:Vn(o==="frontal"?ve:o==="side"?fe:pe,.1),border:1,borderColor:o==="frontal"?ve:o==="side"?fe:pe},children:e.jsx(le,{direction:"row",alignItems:"center",spacing:1,children:cn?e.jsxs(e.Fragment,{children:[e.jsx(Ot,{sx:{color:o==="frontal"?ve:o==="side"?fe:pe}}),e.jsx(A,{variant:"body2",children:l("environment.dragHint")})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ht,{sx:{color:o==="frontal"?ve:o==="side"?fe:pe}}),e.jsx(A,{variant:"body2",children:l(o==="frontal"?"environment.drawFrontalHint":o==="side"?"environment.drawSideHint":"environment.drawCornerHint")})]})})}),e.jsxs(b,{ref:V,sx:{width:"100%",position:"relative",borderRadius:2,overflow:"hidden",bgcolor:"grey.100",...!Le&&{minHeight:$t},...L&&{flex:1,minHeight:0,display:"flex",alignItems:"center",justifyContent:"center"}},children:[e.jsx("canvas",{ref:B,width:ue,height:Ie,style:{display:"block",width:ue||"100%",height:Ie||"auto",cursor:ln()},onMouseDown:Qe,onMouseMove:Ve,onMouseUp:he,onMouseLeave:Se}),(ye||Ue)&&e.jsx(le,{alignItems:"center",justifyContent:"center",spacing:1.5,sx:{position:"absolute",inset:0,bgcolor:"grey.100"},children:ye?e.jsxs(e.Fragment,{children:[e.jsx(rn,{}),e.jsx(A,{variant:"body2",color:"text.secondary",children:l("environment.loadingImage")})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ut,{fontSize:"large",color:"disabled"}),e.jsx(A,{variant:"body2",color:"text.secondary",children:l("environment.imageLoadFailed")})]})}),!L&&e.jsx(Be,{size:"small",onClick:()=>re(!0),"aria-label":l("environment.fullscreen"),sx:{position:"absolute",top:8,right:8,bgcolor:"background.paper",boxShadow:1,"&:hover":{bgcolor:"background.paper"}},children:e.jsx(Tt,{fontSize:"small"})})]}),e.jsxs(le,{direction:"row",spacing:2,sx:{mt:2},flexWrap:"wrap",useFlexGap:!0,children:[e.jsxs(A,{variant:"caption",color:"text.secondary",children:[e.jsx(b,{component:"span",sx:{dis
1play:"inline-block",width:12,height:12,bgcolor:ve,borderRadius:.5,mr:.5,verticalAlign:"middle"}}),l("environment.frontal"),": ",l(E?"environment.defined":"environment.notSet")]}),e.jsxs(A,{variant:"caption",color:"text.secondary",children:[e.jsx(b,{component:"span",sx:{display:"inline-block",width:12,height:12,bgcolor:fe,borderRadius:.5,mr:.5,verticalAlign:"middle"}}),l("environment.side"),": ",l(I?"environment.defined":"environment.notSet")]}),e.jsxs(A,{variant:"caption",color:"text.secondary",children:[e.jsx(b,{component:"span",sx:{display:"inline-block",width:12,height:12,bgcolor:pe,borderRadius:.5,mr:.5,verticalAlign:"middle"}}),l("environment.corner"),": ",l(S?"environment.defined":"environment.notSet")]})]})]});return L?e.jsx(zn,{fullScreen:!0,open:!0,onClose:()=>re(!1),children:e.jsxs(b,{sx:{height:"100%",display:"flex",flexDirection:"column",p:3},children:[e.jsxs(le,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{mb:2},children:[e.jsx(A,{variant:"h6",children:l("environment.editorTitle")}),e.jsxs(le,{direction:"row",alignItems:"center",spacing:1,children:[v&&e.jsx(je,{variant:"contained",onClick:v,disabled:g||H,startIcon:H?e.jsx(rn,{size:18,color:"inherit"}):e.jsx(_t,{}),sx:{px:3,minWidth:120},children:l("environment.saveChanges")}),e.jsx(Be,{onClick:()=>re(!1),"aria-label":l("environment.exitFullscreen"),children:e.jsx(Bt,{})})]})]}),Je]})}):e.jsx(b,{children:Je})}function kn(n,j,u,i,h){const M=qt[h];n.beginPath(),n.moveTo(j[0][0]*i,j[0][1]*i);for(let v=1;v<j.length;v++)n.lineTo(j[v][0]*i,j[v][1]*i);n.closePath(),n.fillStyle=vn(u,M.fillAlpha),n.fill(),n.strokeStyle=vn(u,M.strokeAlpha),n.lineWidth=M.lineWidth,n.setLineDash(M.lineDash),n.stroke(),n.setLineDash([])}function es(n,j,u,i,h){const M=j.map(B=>B[0]),v=j.map(B=>B[1]),g=Math.min(...M)*i,H=Math.max(...M)*i,T=Math.min(...v)*i,l=Math.max(...v)*i,O=(g+H)/2,V=(T+l)/2;[{type:"nw",x:g,y:T},{type:"n",x:O,y:T},{type:"ne",x:H,y:T},{type:"e",x:H,y:V},{type:"se",x:H,y:l},{type:"s",x:O,y:l},{type:"sw",x:g,y:l},{type:"w",x:g,y:V}].forEach(({type:B,x:J,y:F})=>{const ee=B===h,o=ee?In+2:In;n.fillStyle=ee?u:"#ffffff",n.strokeStyle=u,n.lineWidth=2,n.beginPath(),n.rect(J-o/2,F-o/2,o,o),n.fill(),n.stroke()})}function ns(n,j,u,i,h){const M=Math.min(j[0],u[0])*h,v=Math.min(j[1],u[1])*h,g=Math.abs(u[0]-j[0])*h,H=Math.abs(u[1]-j[1])*h;n.fillStyle=vn(i,.3),n.fillRect(M,v,g,H),n.strokeStyle=i,n.lineWidth=2,n.setLineDash([5,5]),n.strokeRect(M,v,g,H),n.setLineDash([])}function ts(n){const j=n.indexOf("?");return j===-1?n:n.slice(0,j)}function vn(n,j){const u=parseInt(n.slice(1,3),16),i=parseInt(n.slice(3,5),16),h=parseInt(n.slice(5,7),16);return`rgba(${u}, ${i}, ${h}, ${j})`}function ss({open:n,onClose:j,environmentId:u}){const{t:i}=an(),{showNotification:h}=Pn(),M=s.useRef(null),v=!!u,{data:g}=vt(u||"",{enabled:v&&n}),H=ft(),T=pt(),l=jt(),O=s.useRef(null),[V,W]=s.useState(null),[B,J]=s.useState(""),[F,ee]=s.useState(""),[o,K]=s.useState(null),[L,re]=s.useState(null),[E,X]=s.useState(null),[I,ne]=s.useState(null),[S,te]=s.useState(null),[w,U]=s.useState(!1),z=s.useCallback((C,x,se)=>{X(C),ne(x),te(se),U(!0)},[]);s.useEffect(()=>{if(n){const C=setTimeout(()=>{M.current?.focus()},300);return()=>clearTimeout(C)}},[n]),s.useEffect(()=>{n&&g&&v&&(J(g.name),ee(g.description||""),re(g.thumbnailUrl||g.imageUrl),X(g.frontalMask??null),ne(g.sideMask??null),te(g.cornerMask??null),U(!0))},[n,g,v]),s.useEffect(()=>()=>{L&&!v&&o&&URL.revokeObjectURL(L)},[L,v,o]);const q=()=>{J(""),ee(""),K(null),W(null),L&&!v&&o&&URL.revokeObjectURL(L),re(null),X(null),ne(null),te(null),U(!1),j()},D=C=>{const x=C[0];if(x){K(x),L&&!v&&URL.revokeObjectURL(L);const se=URL.createObjectURL(x);re(se)}},Z=C=>{const x=C.target.files?.[0]??null;C.target.value="",x&&W(x)},Y=async()=>{if(!(!V||!u))try{await l.mutateAsync({id:u,imageFile:V}),h(i("environments.replaceImageSuccess"),"success"),W(null)}catch(C){const x=C?.message||i("environments.replaceImageError");h(x,"error")}},ce=async()=>{if(!B.trim())return h(i("environments.nameError"),"error"),!1;if(!u)return!1;try{return await T.mutateAsync({id:u,request:{name:B.trim(),description:F.trim()||void 0,frontalMask:E,sideMask:I,cornerMask:S}}),h(i("environments.updatedSuccess"),"success"),!0}catch(C){const x=C?.message||i("environments.updatedError");return h(x,"error"),!1}},de=async()=>
1{if(v){await ce()&&q();return}if(!B.trim()){h(i("environments.nameError"),"error");return}if(!o){h(i("environments.selectImageError"),"error");return}try{await H.mutateAsync({name:B.trim(),description:F.trim()||void 0,imageFile:o}),h(i("environments.createdSuccess"),"success"),q()}catch(C){const x=C?.message||i("environments.createdError");h(x,"error")}},be=H.isPending||T.isPending,me=(C,x)=>!C&&!x?!0:!C||!x||C.points.length!==x.points.length?!1:C.points.every((se,c)=>se[0]===x.points[c][0]&&se[1]===x.points[c][1]),Pe=v&&g?B!==g.name||F!==(g.description||"")||!me(E,g.frontalMask)||!me(I,g.sideMask)||!me(S,g.cornerMask):!0,ze=v?B.trim()&&Pe:B.trim()&&o;return e.jsxs(Xn,{anchor:"right",open:n,onClose:q,slotProps:{paper:qn("wide")},children:[e.jsxs(b,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[e.jsx(Yn,{title:i(v?"environments.drawerEditTitle":"environments.drawerAddTitle"),subtitle:i(v?"environments.drawerEditSubtitle":"environments.drawerAddSubtitle"),onClose:q}),e.jsxs(Gn,{children:[v&&g&&e.jsx(b,{sx:{mb:3},children:e.jsx(Ye,{label:g.status===_.Active?i("environments.statusActive"):i("environments.statusInactive"),color:Xt(g.status),size:"small"})}),v&&g?e.jsxs(b,{sx:{mb:3},children:[e.jsx(A,{variant:"subtitle2",color:"text.secondary",sx:{mb:2},children:i("environments.backgroundImageAndMasks")}),e.jsx(Jt,{imageUrl:g.imageUrl,frontalMask:w?E:g.frontalMask??null,sideMask:w?I:g.sideMask??null,cornerMask:w?S:g.cornerMask??null,onMasksChange:z,onReplaceImage:()=>O.current?.click(),onSave:()=>{ce()},saveDisabled:!ze,isSaving:be}),e.jsx("input",{ref:O,type:"file",accept:"image/jpeg,image/png,image/webp",hidden:!0,onChange:Z})]}):e.jsxs(e.Fragment,{children:[e.jsx(A,{variant:"subtitle2",color:"text.secondary",sx:{mb:2},children:i("environments.backgroundImageLabel")}),L?e.jsxs(b,{sx:{mb:3},children:[e.jsx(b,{component:"img",src:L,alt:"Preview",sx:{width:"100%",maxHeight:200,objectFit:"cover",borderRadius:2,mb:1}}),e.jsx(A,{variant:"body2",color:"primary",sx:{cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>{K(null),L&&URL.revokeObjectURL(L),re(null)},children:i("environments.changeImage")})]}):e.jsx(b,{sx:{mb:3},children:e.jsx(Ft,{onFilesSelected:D,multiple:!1,maxSize:100*1024*1024})})]}),e.jsx(A,{variant:"subtitle2",color:"text.secondary",sx:{mb:2},children:i("environments.detailsLabel")}),e.jsx(Ge,{inputRef:M,label:i("environments.nameLabel"),required:!0,fullWidth:!0,value:B,onChange:C=>J(C.target.value),placeholder:i("environments.namePlaceholder"),sx:{mb:2}}),e.jsx(Ge,{label:i("environments.descriptionLabel"),fullWidth:!0,multiline:!0,rows:2,value:F,onChange:C=>ee(C.target.value),placeholder:i("environments.descriptionPlaceholder")})]}),e.jsx(Kn,{onCancel:q,onSubmit:de,submitLabel:i(v?"environments.drawerSave":"environments.drawerAdd"),submitDisabled:!ze,isSubmitting:be})]}),e.jsx(sn,{open:!!V,title:i("environments.replaceImageConfirmTitle"),message:i("environments.replaceImageConfirmMessage",{fileName:V?.name}),confirmLabel:i("environments.replaceImageConfirm"),confirmColor:"warning",loading:l.isPending,onConfirm:Y,onCancel:()=>W(null)})]})}const An=4,is=280,rs=180,as=80,En=2,os=5;function ls(){const[n,j]=s.useState(An*En);return s.useEffect(()=>{const u=()=>{const i=window.innerHeight-rs-as,h=Math.floor(i/is),M=Math.max(En,Math.min(os,h));j(M*An)};return u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)},[]),n}function cs(n,j){const[u,i]=s.useState(n);return s.useEffect(()=>{const h=setTimeout(()=>{i(n)},j);return()=>{clearTimeout(h)}},[n,j]),u}function Es(){const{t:n}=an(),j=Zn(),u=Qn(j.breakpoints.down("sm")),{showNotification:i}=Pn(),{canManageEnvironments:h,isPlatformAdministrator:M}=$n(),{data:v}=Jn(),g=h&&(v?.allowEnvironmentManagement??!1),H=t=>M||t.type===$.Custom&&g,T=t=>M&&t.type===$.Custom,l=t=>M&&t.type===$.Custom,O=M||g,V=M||(v?.allowEnvironmentManagement??!1),[W,B]=et(),J=ls(),F=Math.max(1,parseInt(W.get("page")??"1",10)),ee=W.get("status"),o=V?ee==="all"?"":ee||_.Active:_.Active,K=W.get("type")||"",L=W.get("sortBy")||ae.NameAsc,re=W.get("search")??"",[E,X]=s.useState(re),I=cs(E,300),ne=s.useRef(I),S=t=>{B(R=>{for(const[Ce,Me]of Object.entries(t))Me===null||Me===""||Ce==="page"&&Me==="1"||Ce==="status"&&Me===_.Active||Ce==="sortBy"&&Me===ae.NameAsc?R.delete(Ce):R.set(Ce,Me);return R})},te=h,w=bt({page:F,pageSize:J,status:o||void 0,type:K||void 0,search:I||void 0,sortBy:L,includeHidden:te},{enabled:!u}),U=yt({pageSize:12,status:o||void 0,type:K||void 0,search:I||void 0,sortBy:L,includeHidden:te}),z=u?void 0:w.data,q=u?U.isLoading:w.isLoading,D=u?U.data?.pages.flatMap(t=>t.items):z?.items,Z=u?U.data?.pages[0]?.totalCount:z?.totalCount,Y=mt(()=>{U.isFetchingNextPage||U.fetchNextPage()},u&&U.hasNextPage===!0),ce=St(),de=Ct(),be=Mt(),me=wt(),Pe=It(),ze=kt(),C=At(),x=Et(),se=Pt();s.useEffect(()=>{I!==ne.current&&(ne.current=I,Se.current||S({search:I||null,page:"1"}))},[I]);const[c,Ke]=s.useState(null),[Le,Ne]=s.useState(!1),[qe,We]=s.useState(!1),[we,ie]=s.useState(!1),[ye,Ue]=s.useState(null),[N,G]=s.useState(null),[De,ue]=s.useState(!1),[Ie,Re]=s.useState(null),[He,_e]=s.useState(!1),[Ze,Qe]=s.useState(0),[Ve,he]=s.useState(!1),Se=s.useRef(!1),ke=()=>{Re(null),ue(!0)},on=(t,R)=>{Ke({el:t.currentTarget,environment:R})},Q=()=>{Ke(null)},ln=(t,R)=>{if(R.stopPropagation(),D){const Ce=D.findIndex(Me=>Me.id===t.id);Qe(Ce>=0?Ce:0),_e(!0)}},$e=(D||[]).map(t=>({src:t.webUrl||t.imageUrl,alt:t.name,title:t.name,downloadUrl:t.imageUrl,downloadFilename:t.name.replace(/\s+/g,"-").replace(/-{2,}/g,"-")})),fn=t=>{Qe(t)},cn=()=>{z?.hasNextPage&&(Se.current=!0,he(!0),S({page:String(F+1)}))},Je=()=>{z?.hasPreviousPage&&(Se.current=!0,he(!0),S({page:String(F-1)}))},r=()=>{z&&z.totalPages>1&&(Se.current=!0,he(!0),S({page:"1"}))},a=()=>{z&&z.totalPages>1&&(Se.current=!0,he(!0),S({page:String(z.totalPages)}))};s.useEffect(()=>{!q&&Ve&&(he(!1),Se.current=!1)},[q,Ve]);const d=()=>{c&&(Re(c.environment.id),ue(!0),Q())},m=()=>{c&&(G(c.environment),Ne(!0),Q())},f=async()=>
1{if(N)try{await ce.mutateAsync(N.id),i(n("environments.deletedSuccess"),"success")}catch{i(n("environments.deletedError"),"error")}Ne(!1),G(null)},p=()=>{c&&(G(c.environment),We(!0),Q())},P=async()=>{if(N)try{await x.mutateAsync(N.id),i(n("environments.promoteSuccess"),"success")}catch{i(n("environments.promoteError"),"error")}We(!1),G(null)},k=()=>{c&&(G(c.environment),ie(!0),Q())},Ae=()=>{ie(!1),G(null)},Ln=t=>{ie(!1),Ue(t)},Dn=()=>{Ue(null),G(null)},Rn=async()=>{if(N&&ye)try{await se.mutateAsync({id:N.id,accountId:ye.id}),i(n("environments.assignSuccess",{account:ye.name}),"success")}catch{i(n("environments.assignError"),"error")}Ue(null),G(null)},Hn=async t=>{try{t.isDefault?(await Pe.mutateAsync(),i(n("environments.removeDefaultSuccess"),"success")):(await me.mutateAsync(t.id),i(n("environments.setDefaultSuccess"),"success"))}catch{i(n("environments.updateError"),"error")}Q()},Fn=async t=>{try{await ze.mutateAsync(t.id),i(n("environments.hideSuccess"),"success")}catch{i(n("environments.hideError"),"error")}Q()},On=async t=>{try{await C.mutateAsync(t.id),i(n("environments.unhideSuccess"),"success")}catch{i(n("environments.unhideError"),"error")}Q()},Tn=async t=>{try{await de.mutateAsync(t.id),i(n("environments.activateSuccess"),"success")}catch{i(n("environments.activateError"),"error")}Q()},Bn=async t=>{try{await be.mutateAsync(t.id),i(n("environments.deactivateSuccess"),"success")}catch{i(n("environments.deactivateError"),"error")}Q()},Nn=(t,R)=>{S({page:String(R)}),document.querySelector("main")?.scrollTo({top:0,behavior:"smooth"})},pn=t=>{const R=t.target.value;S({status:R||"all",page:"1"})},jn=t=>{const R=t.target.value;S({type:R||null,page:"1"})},bn=t=>{const R=t.target.value;S({sortBy:R,page:"1"})},yn=()=>{X("")},Wn=E||o||K;return e.jsxs(b,{sx:{pb:{xs:O?10:0,sm:0}},children:[e.jsxs(b,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:{xs:2,sm:3}},children:[e.jsxs(b,{sx:{display:{xs:"none",sm:"block"}},children:[e.jsx(A,{variant:"h4",fontWeight:700,gutterBottom:!0,children:n("environments.title")}),e.jsx(A,{color:"text.secondary",children:n(O?"environments.subtitle":"environments.subtitleReadonly")})]}),!u&&O&&e.jsx(je,{variant:"contained",startIcon:e.jsx(dn,{}),onClick:ke,children:n("environments.addButton")})]}),e.jsxs(b,{sx:{display:{xs:"flex",sm:"none"},flexDirection:"column",gap:1.5,mb:2},children:[e.jsx(Ge,{size:"small",placeholder:n("environments.searchPlaceholder"),value:E,onChange:t=>X(t.target.value),fullWidth:!0,slotProps:{input:{startAdornment:e.jsx(Xe,{position:"start",children:e.jsx(tn,{color:"action"})}),endAdornment:E&&e.jsx(Xe,{position:"end",children:e.jsx(Be,{size:"small",onClick:yn,edge:"end",children:e.jsx(Sn,{fontSize:"small"})})})}}}),e.jsxs(le,{direction:"row",spacing:1.5,children:[e.jsxs(Fe,{size:"small",sx:{flex:1},children:[e.jsx(Oe,{id:"type-filter-label-m",shrink:!0,children:n("environments.typeLabel")}),e.jsxs(Te,{labelId:"type-filter-label-m",value:K,label:n("environments.typeLabel"),onChange:jn,displayEmpty:!0,renderValue:t=>t?t===$.BuiltIn?n("environments.builtIn"):n("environments.custom"):n("environments.all"),children:[e.jsx(y,{value:"",children:n("environments.all")}),e.jsx(y,{value:$.BuiltIn,children:n("environments.builtIn")}),e.jsx(y,{value:$.Custom,children:n("environments.custom")})]})]}),V&&e.jsxs(Fe,{size:"small",sx:{flex:1},children:[e.jsx(Oe,{id:"status-filter-label-m",shrink:!0,children:n("environments.statusLabel")}),e.jsxs(Te,{labelId:"status-filter-label-m",value:o,label:n("environments.statusLabel"),onChange:pn,displayEmpty:!0,renderValue:t=>t?t===_.Active?n("environments.statusActive"):n("environments.statusInactive"):n("environments.all"),children:[e.jsx(y,{value:"",children:n("environments.all")}),e.jsx(y,{value:_.Active,children:n("environments.statusActive")}),e.jsx(y,{value:_.Inactive,children:n("environments.statusInactive")})]})]}),e.jsxs(Fe,{size:"small",sx:{flex:1},children:[e.jsx(Oe,{id:"sort-by-label-m",children:n("environments.sortByLabel")}),e.jsxs(Te,{labelId:"sort-by-label-m",value:L,label:n("environments.sortByLabel"),onChange:bn,children:[e.jsx(y,{value:ae.NameAsc,children:n("environments.sort
1NameAsc")}),e.jsx(y,{value:ae.NameDesc,children:n("environments.sortNameDesc")}),e.jsx(y,{value:ae.CreatedAtDesc,children:n("environments.sortNewest")}),e.jsx(y,{value:ae.CreatedAtAsc,children:n("environments.sortOldest")})]})]})]}),Z!==void 0&&e.jsx(A,{variant:"body2",color:"text.secondary",children:n("environments.count",{count:Z})})]}),e.jsxs(le,{direction:"row",spacing:2,sx:{display:{xs:"none",sm:"flex"},mb:3,width:"100%"},alignItems:"center",children:[e.jsx(Ge,{size:"small",placeholder:n("environments.searchPlaceholder"),value:E,onChange:t=>X(t.target.value),sx:{flex:1,minWidth:200},slotProps:{input:{startAdornment:e.jsx(Xe,{position:"start",children:e.jsx(tn,{color:"action"})}),endAdornment:E&&e.jsx(Xe,{position:"end",children:e.jsx(Be,{size:"small",onClick:yn,edge:"end",children:e.jsx(Sn,{fontSize:"small"})})})}}}),e.jsxs(Fe,{size:"small",sx:{minWidth:120},children:[e.jsx(Oe,{id:"type-filter-label",shrink:!0,children:n("environments.typeLabel")}),e.jsxs(Te,{labelId:"type-filter-label",value:K,label:n("environments.typeLabel"),onChange:jn,displayEmpty:!0,renderValue:t=>t?t===$.BuiltIn?n("environments.builtIn"):n("environments.custom"):n("environments.all"),children:[e.jsx(y,{value:"",children:n("environments.all")}),e.jsx(y,{value:$.BuiltIn,children:n("environments.builtIn")}),e.jsx(y,{value:$.Custom,children:n("environments.custom")})]})]}),V&&e.jsxs(Fe,{size:"small",sx:{minWidth:140},children:[e.jsx(Oe,{id:"status-filter-label",shrink:!0,children:n("environments.statusLabel")}),e.jsxs(Te,{labelId:"status-filter-label",value:o,label:n("environments.statusLabel"),onChange:pn,displayEmpty:!0,renderValue:t=>t?t===_.Active?n("environments.statusActive"):n("environments.statusInactive"):n("environments.all"),children:[e.jsx(y,{value:"",children:n("environments.all")}),e.jsx(y,{value:_.Active,children:n("environments.statusActive")}),e.jsx(y,{value:_.Inactive,children:n("environments.statusInactive")})]})]}),e.jsxs(Fe,{size:"small",sx:{minWidth:180},children:[e.jsx(Oe,{id:"sort-by-label",children:n("environments.sortByLabel")}),e.jsxs(Te,{labelId:"sort-by-label",value:L,label:n("environments.sortByLabel"),onChange:bn,children:[e.jsx(y,{value:ae.NameAsc,children:n("environments.sortNameAsc")}),e.jsx(y,{value:ae.NameDesc,children:n("environments.sortNameDesc")}),e.jsx(y,{value:ae.CreatedAtDesc,children:n("environments.sortNewest")}),e.jsx(y,{value:ae.CreatedAtAsc,children:n("environments.sortOldest")})]})]}),Z!==void 0&&e.jsx(A,{variant:"body2",color:"text.secondary",sx:{ml:"auto"},children:n("environments.count",{count:Z})})]}),q?e.jsx(en,{container:!0,spacing:3,children:Array.from({length:J},(t,R)=>R+1).map(t=>e.jsx(en,{size:{xs:12,sm:6,md:3},children:e.jsxs(nt,{children:[e.jsx(mn,{variant:"rectangular",height:160}),e.jsxs(un,{children:[e.jsx(mn,{width:"60%"}),e.jsx(mn,{width:"40%"})]})]})},t))}):Z===0?e.jsx(xn,{variant:"outlined",sx:{borderRadius:2},children:e.jsx(un,{sx:{textAlign:"center",py:8},children:Wn?e.jsxs(e.Fragment,{children:[e.jsx(tn,{sx:{fontSize:64,color:"text.secondary",mb:2}}),e.jsx(A,{variant:"h6",color:"text.secondary",gutterBottom:!0,children:n("environments.noMatchingTitle")}),e.jsx(A,{color:"text.secondary",sx:{mb:3},children:n("environments.noMatchingDescription")}),e.jsx(je,{variant:"outlined",onClick:()=>{X(""),S({search:null,type:null,status:null,page:"1"})},children:n("environments.clearFilters")})]}):e.jsxs(e.Fragment,{children:[e.jsx(tt,{sx:{fontSize:64,color:"text.secondary",mb:2}}),e.jsx(A,{variant:"h6",color:"text.secondary",gutterBottom:!0,children:n("environments.emptyTitle")}),e.jsx(A,{color:"text.secondary",sx:{mb:3},children:n(O?"environments.emptyDescriptionManage":"environments.emptyDescriptionView")}),O&&e.jsx(je,{variant:"contained",startIcon:e.jsx(dn,{}),onClick:ke,children:n("environments.addButton")})]})})}):e.jsx(en,{container:!0,spacing:3,children:D?.map(t=>e.jsx(en,{size:{xs:12,sm:6,md:3},children:e.jsxs(xn,{variant:"outlined",elevation:0,sx:{position:"relative",bgcolor:"background.paper",borderColor:"grey.300",borderRadius:2,overflow:"hidden"},children:[e.jsxs(b,{sx:{position:"relative"},children:[e.jsx(Nt,{component:"img",height:160,image:t.thumbnailUrl||t.imageUrl,alt:t.name,sx:{objectFit:"cover"}}),e.jsxs(le,{direction:"row",spacing:.5,sx:{position:"absolute",top:8,left:8},children:[t.type===$.BuiltIn&&e.jsx(Ye,{label:n("environments.builtInChip"),size:"small",sx:{bgcolor:"rgba(0, 0, 0, 0.6)",color:"white",fontWeight:500}}),t.isDefault&&e.jsx(Ye,{label:n("environments.defaultChip"),color:"primary",size:"small",icon:e.jsx(Mn,{})}),t.status===_.Inactive&&e.jsx(Ye,{label:n("environments.statusInactive"),size:"small",sx:{bgcolor:"rgba(0, 0, 0, 0.6)",color:"white",fontWeight:500}}),t.isHidden&&e.jsx(Ye,{label:n("environments.hiddenChip"),size:"small",icon:e.jsx(wn,{}),sx:{bgcolor:"rgba(0, 0, 0, 0.6)",color:"white",fontWeight:500,"& .MuiChip-icon":{color:"white"}}})]}),e.jsx(Be,{sx:{position:"absolute",top:8,right:8,bgcolor:"background.paper","&:hover":{bgcolor:"grey.100"}},onClick:R=>ln(t,R),title:n("environments.previewImage"),children:e.jsx(xt,{})})]}),e.jsxs(un,{children:[e.jsx(A,{variant:"subtitle1",fontWeight:600,noWrap:!0,children:t.name}),e.jsxs(le,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(A,{variant:"caption",color:"text.secondary",children:st(t.createdAt,"MMM d, yyyy")}),h&&e.jsx(Be,{size:"small",onClick:R=>on(R,t),sx:{mr:-1},children:e.jsx(dt,{fontSize:"small"})})]})]})]})},t.id))}),u?e.jsxs(e.Fragment,{children:[e.jsx(b,{ref:Y,sx:{height:1}}),U.isFetchingNextPage&&e.jsx(b,{sx:{display:"flex",justifyContent:"center",py:3},children:e.jsx(rn,{size:28})})]}):z&&z.totalPages>1&&e.jsx(b,{sx:{display:"flex",justifyContent:"center",mt:4},children:e.jsx(ut,{count:z.totalPages,page:F,onChange:Nn,color:"primary",size:"large",showFirstButton:!0,showLastButton:!0})}),e.jsxs(it,{anchorEl:c?.el,open:!!c,onClose:Q,children:[c&&H(c.environment)&&e.jsxs(y,{onClick:d,children:[e.jsx(xe,{children:e.jsx(nn,{fontSize:"small"})}),e.jsx(oe,{children:n("environments.menuEdit")})]}),h&&e.jsxs(y,{onClick:()=>c&&Hn(c.environment),children:[e.jsx(xe,{children:c?.environment.isDefault?e.jsx(Vt,{fontSize:"small"}):e.jsx(Mn,{fontSize:"small"})}),e.jsx(oe,{children:c?.environment.isDefault?n("environments.menuRemoveDefault"):n("environments.menuSetDefault")})]}),c&&H(c.environment)&&c.environment.status===_.Inactive&&e.jsxs(y,{onClick:()=>Tn(c.environment),children:[e.jsx(xe,{children:e.jsx(rt,{fontSize:"small",color:"success"})}),e.jsx(oe,{children:n("environments.menuActivate")})]}),c&&H(c.environment)&&c.environment.status===_.Active&&e.jsxs(y,{onClick:()=>Bn(c.environment),children:[e.jsx(xe,{children:e.jsx(ht,{fontSize:"small"})}),e.jsx(oe,{children:n("environments.menuDeactivate")})]}),h&&c?.environment.type===$.BuiltIn&&!c?.environment.isHidden&&e.jsxs(y,{onClick:()=>c&&Fn(c.environment),children:[e.jsx(xe,{children:e.jsx(wn,{fontSize:"small"})}),e.jsx(oe,{children:n("environments.menuHide")})]}),h&&c?.environment.type===$.BuiltIn&&c?.environment.isHidden&&e.jsxs(y,{onClick:()=>c&&On(c.environment),children:[e.jsx(xe,{children:e.jsx(gn,{fontSize:"small"})}),e.jsx(oe,{children:n("environments.menuUnhide")})]}),c&&T(c.environment)&&e.jsxs(y,{onClick:p,children:[e.jsx(xe,{children:e.jsx(at,{fontSize:"small"})}),e.jsx(oe,{children:n("environments.menuPromoteToBuiltIn")})]}),c&&l(c.environment)&&e.jsxs(y,{onClick:k,children:[e.jsx(xe,{children:e.jsx(gt,{fontSize:"small"})}),e.jsx(oe,{children:n("environments.menuAssignOwnership")})]}),c&&H(c.environment)&&e.jsxs(y,{onClick:m,sx:{color:"error.main"},children:[e.jsx(xe,{children:e.jsx(ot,{fontSize:"small",sx:{color:"error.main"}})}),e.jsx(oe,{children:n("environments.menuDelete")})]})]}),e.jsx(ss,{open:De,onClose:()=>{ue(!1),Re(null)},environmentId:Ie}),e.jsx(sn,{open:Le,title:n("environments.deleteTitle"),message:n("environments.deleteMessage",{name:N?.name}),confirmLabel:n("common.delete"),confirmColor:"error",loading:ce.isPending,onConfirm:f,onCancel:()=>Ne(!1)}),e.jsx(sn,{open:qe,title:n("environments.promoteTitle"),message:n("environments.promoteMessage",{name:N?.name}),confirmLabel:n("environments.promoteConfirm"),loading:x.isPending,onConfirm:P,onCancel:()=>We(!1)}),we&&e.jsx(Kt,{onSelect:Ln,onCancel:Ae}),e.jsx(sn,{open:!!ye,title:n("environments.assignConfirmTitle"),message:n("environments.assignConfirmMessage",{name:N?.name,account:ye?.name}),confirmLabel:n("environments.assignConfirm"),loading:se.isPending,onConfirm:Rn,onCancel:Dn}),e.jsx(lt,{open:He,onClose:()=>_e(!1),images:$e,index:Ze,onIndexChange:fn,hasNextPage:z?.hasNextPage,hasPreviousPage:z?.hasPreviousPage,onLoadNextPage:cn,onLoadPreviousPage:Je,onLoadFirstPage:r,onLoadLastPage:a,totalPages:z?.totalPages,currentPage:z?.page,isLoadingPage:Ve}),u&&O&&e.jsx(ct,{color:"primary",onClick:ke,sx:{position:"fixed",bottom:24,right:24},children:e.jsx(dn,{})})]})}export{Es as EnvironmentsPage};
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.