1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[49200],{233:(e,t,n)=>{n.d(t,{_:()=>r,e:()=>o});var a=n(12115);function r(e){let[t,n]=(0,a.useState)(null),[r,o]=(0,a.useState)(!!e);return(0,a.useEffect)(()=>{if(!e){n(null),o(!1);return}let t=!1;return o(!0),fetch("/api/builds/verification-manifest?presetId=".concat(encodeURIComponent(e))).then(e=>e.ok?e.json():null).then(e=>{var a;t||n(null!=(a=null==e?void 0:e.manifest)?a:null)}).catch(()=>{t||n(null)}).finally(()=>{t||o(!1)}),()=>{t=!0}},[e]),{manifest:t,loading:r}}let o={schemaVersion:1,tier:1,durationEstimate:"",requirementsSummary:"",steps:[{id:"__empty__",type:"probe",title:"",purpose:"",transport:"pi_ws",confirm:{method:"http_ping"}}]}},1244:(e,t,n)=>{n.r(t),n.d(t,{Avatar:()=>m,AvatarFallback:()=>h,AvatarIcon:()=>f,AvatarImage:()=>p,avatarVariants:()=>c});var a=n(95155),r=n(12115),o=n(63366),s=n(83101),i=n(25016);let l=r.createContext("default"),c=(0,s.F)("relative flex shrink-0 overflow-hidden",{variants:{size:{lg:"h-12 w-12 rounded-xl",default:"h-10 w-10 rounded-lg",sm:"h-8 w-8 rounded-lg",xs:"h-6 w-6 rounded-sm",xxs:"h-5 w-5 rounded"}},defaultVariants:{size:"default"}}),d={lg:"text-sm",default:"text-sm",sm:"text-sm",xs:"text-xs",xxs:"text-xs"},u={lg:28,default:24,sm:20,xs:14,xxs:12};function m(e){let{className:t,size:n="default",...r}=e;return(0,a.jsx)(l.Provider,{value:null!=n?n:"default",children:(0,a.jsx)(o.bL,{"data-slot":"avatar",className:(0,i.cn)(c({size:n}),t),...r})})}function p(e){let{className:t,...n}=e;return(0,a.jsx)(o._V,{"data-slot":"avatar-image",className:(0,i.cn)("aspect-square h-full w-full rounded-[inherit] object-cover",t),...n})}function h(e){let{className:t,...n}=e,s=r.useContext(l);return(0,a.jsx)(o.H4,{"data-slot":"avatar-fallback",className:(0,i.cn)("flex h-full w-full items-center justify-center rounded-[inherit] bg-muted font-semibold text-muted-foreground",d[s],t),...n})}function f(e){let{className:t,children:n}=e,o=r.useContext(l);return(0,a.jsx)("span",{"data-slot":"avatar-icon","aria-hidden":!0,className:(0,i.cn)("flex h-full w-full items-center justify-center rounded-[inherit] bg-muted text-muted-foreground",t),children:n(u[o])})}},5233:(e,t,n)=>{n.d(t,{E:()=>r});var a=n(12115);function r(e){let[t,n]=(0,a.useState)(0),[r,o]=(0,a.useState)(()=>new Set),[s,i]=(0,a.useState)({}),l=(0,a.useRef)(e);(0,a.useEffect)(()=>{l.current!==e&&(l.current=e,n(0),o(new Set),i({}))},[e]);let c=e.steps.length,d=Math.min(t,c-1),u=e.steps[d],m=r.has(u.id),p=d===c-1,h=(0,a.useCallback)(e=>{o(e=>{if(e.has(u.id))return e;let t=new Set(e);return t.add(u.id),t}),e&&i(t=>({...t,...e}))},[u.id]),f=(0,a.useCallback)(()=>{n(e=>Math.min(e+1,c-1))},[c]),g=(0,a.useCallback)(()=>!(d<=0)&&(n(e=>Math.max(Math.min(e,c-1)-1,0)),!0),[d,c]),x=(0,a.useCallback)(()=>{n(0),o(new Set),i({})},[]);return(0,a.useMemo)(()=>({subStepIndex:d,currentStep:u,completedStepIds:r,capturedValues:s,isCurrentStepComplete:m,isFinalStep:p,totalSteps:c,completeCurrentStep:h,goNext:f,goBack:g,reset:x}),[d,u,r,s,m,p,c,h,f,g,x])}},9265:(e,t,n)=>{n.d(t,{HT:()=>a,Pw:()=>o,aG:()=>r});let a={name:"",description:"",country:"",city:"",gallery:[],tags:[]},r=80,o=12},11854:(e,t,n)=>{n.d(t,{B:()=>a});class a extends Error{constructor(e="You already have a build with that name."){super(e),this.name="NameTakenError"}}},12857:(e,t,n)=>{n.d(t,{I:()=>a.I});var a=n(43392)},23037:(e,t,n)=>{n.d(t,{p:()=>i});var a=n(95155);n(12115);var r=n(83101),o=n(25016);let s=(0,r.F)("flex w-full min-w-0 border text-foreground-strong transition-colors outline-none placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground file:text-foreground file:inline-flex file:border-0 file:bg-transparent file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 focus-visible:ring-2 focus-visible:ring-ring aria-invalid:border-destructive aria-invalid:ring-0 aria-invalid:focus-visible:border-destructive aria-invalid:focus-visible:ring-2 aria-invalid:focus-visible:ring-destructive",{variants:{variant:{default:"border-border bg-card focus-visible:border-border-emphasis",ghost:"border-transparent bg-transparent hover:bg-card-hovered focus-visible:bg-card-hovered"},size:{xs:"h-6 px-1.5 py-1 gap-1 rounded-[4px] text-xs file:h-4 file:text-xs [&_svg:not([class*='size-'])]:size-3",sm:"h-8 px-2 py-[5.5px] gap-1.5 rounded-[8px] text-base md:text-sm file:h-6 file:text-xs",default:"h-9 px-3 py-[7.5px] gap-2 rounded-[8px] text-base md:text-sm file:h-7 file:text-sm",lg:"h-10 px-4 py-[9.5px] gap-3 rounded-[8px] text-base md:text-sm file:h-8 file:text-sm"}},defaultVariants:{variant:"default",size:"default"}});function i(e){let{className:t,type:n,variant:r,size:i,...l}=e;return(0,a.jsx)("input",{type:n,"data-slot":"input",className:(0,o.cn)(s({variant:r,size:i}),t),...l})}}
1,50288:(e,t,n)=>{n.d(t,{u:()=>s});class a extends Error{constructor(e,t,n){super(e),this.code=t,this.context=n,this.name="CentralDocsAPIError"}}var r=n(20094),o=n(95704);class s{static async uploadFile(e,t,n){try{let o=await fetch("/api/central-docs/presigned-upload-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:e.name,fileType:e.type,fileSize:e.size,organizationId:t})});if(!o.ok){let e=(await o.json().catch(()=>({}))).error||"Failed to get presigned URL";throw(0,r.VW)(o.status,e)&&(0,r.ef)("media-upload","File size exceeds the limit for your plan."),new a(e,"PRESIGNED_URL_ERROR")}let{presignedUrl:s,s3Key:i,bucket:l}=await o.json(),c=new XMLHttpRequest,d=new Promise((t,r)=>{n&&(c.upload.onprogress=e=>{if(e.lengthComputable){let t=Math.round(e.loaded/e.total*100);n(t)}}),c.onload=()=>{if(c.status>=200&&c.status<300){let e=encodeURIComponent(i).replace(/%2F/g,"/"),n="https://".concat(l,".s3.amazonaws.com/").concat(e);t(n)}else r(new a("Upload failed with status ".concat(c.status),"UPLOAD_ERROR"))},c.onerror=()=>{r(new a("Network error during upload","NETWORK_ERROR"))},c.open("PUT",s),c.setRequestHeader("Content-Type",e.type),c.send(e)}),u=await d;return{s3Key:i,bucket:l,publicUrl:u,signedUrl:u}}catch(e){throw console.error("Media upload failed:",e),e}}static async uploadBuildImage(e,t,n){try{let o=await fetch("/api/builds/presigned-upload-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:e.name,fileType:e.type,fileSize:e.size,organizationId:t})});if(!o.ok){let e=(await o.json().catch(()=>({}))).error||"Failed to get presigned URL";throw(0,r.VW)(o.status,e)&&(0,r.ef)("media-upload","File size exceeds the limit for your plan."),new a(e,"PRESIGNED_URL_ERROR")}let{presignedUrl:s,s3Key:i,bucket:l,region:c,cacheControl:d}=await o.json(),u=new XMLHttpRequest,m=new Promise((t,r)=>{n&&(u.upload.onprogress=e=>{if(e.lengthComputable){let t=Math.round(e.loaded/e.total*100);n(t)}}),u.onload=()=>{if(u.status>=200&&u.status<300){let e=encodeURIComponent(i).replace(/%2F/g,"/"),n="https://".concat(l,".s3.").concat(c,".amazonaws.com/").concat(e);t(n)}else r(new a("Upload failed with status ".concat(u.status),"UPLOAD_ERROR"))},u.onerror=()=>{r(new a("Network error during upload","NETWORK_ERROR"))},u.open("PUT",s),u.setRequestHeader("Content-Type",e.type),d&&u.setRequestHeader("Cache-Control",d),u.send(e)}),p=await m;return{s3Key:i,bucket:l,publicUrl:p,signedUrl:p}}catch(e){throw console.error("Build image upload failed:",e),e}}static parseS3Url(e){try{let t=e.match(/(central-docs-(?:dev|prod))\.s3(?:\.[^.]+)?\.amazonaws\.com\/(.+)/);if(!t)return null;let n=t[1],a=t[2],r=a;try{let e=decodeURIComponent(a);if(e.includes("%25")){let t=e;for(;t.includes("%25")&&t!==decodeURIComponent(t);)t=decodeURIComponent(t);r=t}else r=e}catch(e){console.warn("Failed to decode S3 key, using as-is:",a),r=a}return{s3Key:r,bucket:n}}catch(t){return console.error("Failed to parse S3 URL:",e,t),null}}static isS3Url(e){return e.includes("central-docs-dev.s3")||e.includes("central-docs-prod.s3")}static invalidateCache(e){this.signedUrlCache.delete(e)}static cleanupExpiredUrls(){let e=Date.now();for(let[t,n]of this.signedUrlCache.entries())n.expires<=e&&this.signedUrlCache.delete(t)}static getBucketFromEnv(){return o.env.CENTRAL_DOCS_BUCKET||"central-docs-dev"}static enforceCacheLimit(){if(this.signedUrlCache.size>=this.MAX_CACHE_SIZE){let e=Array.from(this.signedUrlCache.entries()).sort((e,t)=>e[1].lastAccessed-t[1].lastAccessed),t=Math.ceil(.2*e.length);for(let n=0;n<t;n++)this.signedUrlCache.delete(e[n][0])}}static getCacheStats(){let e=this.cacheHits+this.cacheMisses;return{size:this.signedUrlCache.size,entries:Array.from(this.signedUrlCache.keys()),totalHits:this.cacheHits,totalMisses:this.cacheMisses,hitRate:e>0?this.cacheHits/e*100:0}}static clearCacheStats(){this.cacheHits=0,this.cacheMisses=0}}s.signedUrlCache=new Map,s.CACHE_BUFFER=3e5,s.MAX_CACHE_SIZE=100,s.cacheHits=0,s.cacheMisses=0,setInterval(()=>{s.cleanupExpiredUrls()},6e5)},50771:(e,t,n)=>{n.d(t,{s:()=>o});var a=n(95155),r=n(12857);function o(e){let{projectName:t}=e,n=(null==t?void 0:t.trim())||"this robot";return(0,a.jsxs)("div",{className:"flex flex-1 flex-col items-center gap-6",children:[(0,a.jsxs)("header",{className:"flex flex-col items-start gap-3 self-stretch",children:[(0,a.jsxs)("h2",{className:"text-2xl font-semibold tracking-tight text-foreground-strong",children:["Verification for ",n," is coming soon."]}),(0,a.jsxs)("p",{className:"text-sm leading-relaxed text-foreground",children:["Right now Tnkr only walks through verification for the Open Duck Mini. You can save your agent today as unverified â when we ship the verification flow for ",n,", you'll be able to come back and finish it from your agent page."]})]}),(0,a.jsxs)("div",{className:"flex w-full flex-col self-stretch overflow-hidden rounded-lg border border-border bg-background",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3",children:[(0,a.jsx)("span",{className:"flex h-10 w-10 items-center justify-center rounded-md bg-muted text-muted-foreground",children:(0,a.jsx)(r.I,{name:"IconCuteRobot",size:20})}),(0,a.jsxs)("div",{className:"flex flex-1 flex-col",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-foreground-strong",children:n}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Verification not yet available"})]}),(0,a.jsx)("span",{className:"rounded-full bg-warning-subtle px-2.5 py-1 text-xs font-medium text-warning-subtle-foreground",children:"Coming soon"})]}),(0,a.jsxs)("div",{className:"flex items-start gap-2 border-t border-border-subtle bg-muted px-4 py-2.5 text-xs text-foreground",children:[(0,a.jsx)(r.I,{name:"IconCircleInfo",size:12,className:"mt-0.5 text-muted-foreground"}),(0,a.jsxs)("span",{children:["Your agent will be saved as unverified. We'll let you know
1when verification opens up for ",n,"."]})]})]})]})}},52315:(e,t,n)=>{n.d(t,{r:()=>a});let a=[{code:"AF",name:"Afghanistan"},{code:"AX",name:"\xc5land Islands"},{code:"AL",name:"Albania"},{code:"DZ",name:"Algeria"},{code:"AS",name:"American Samoa"},{code:"AD",name:"Andorra"},{code:"AO",name:"Angola"},{code:"AI",name:"Anguilla"},{code:"AQ",name:"Antarctica"},{code:"AG",name:"Antigua and Barbuda"},{code:"AR",name:"Argentina"},{code:"AM",name:"Armenia"},{code:"AW",name:"Aruba"},{code:"AU",name:"Australia"},{code:"AT",name:"Austria"},{code:"AZ",name:"Azerbaijan"},{code:"BS",name:"Bahamas"},{code:"BH",name:"Bahrain"},{code:"BD",name:"Bangladesh"},{code:"BB",name:"Barbados"},{code:"BY",name:"Belarus"},{code:"BE",name:"Belgium"},{code:"BZ",name:"Belize"},{code:"BJ",name:"Benin"},{code:"BM",name:"Bermuda"},{code:"BT",name:"Bhutan"},{code:"BO",name:"Bolivia"},{code:"BA",name:"Bosnia and Herzegovina"},{code:"BW",name:"Botswana"},{code:"BV",name:"Bouvet Island"},{code:"BR",name:"Brazil"},{code:"IO",name:"British Indian Ocean Territory"},{code:"VG",name:"British Virgin Islands"},{code:"BN",name:"Brunei"},{code:"BG",name:"Bulgaria"},{code:"BF",name:"Burkina Faso"},{code:"BI",name:"Burundi"},{code:"KH",name:"Cambodia"},{code:"CM",name:"Cameroon"},{code:"CA",name:"Canada"},{code:"CV",name:"Cape Verde"},{code:"BQ",name:"Caribbean Netherlands"},{code:"KY",name:"Cayman Islands"},{code:"CF",name:"Central African Republic"},{code:"TD",name:"Chad"},{code:"CL",name:"Chile"},{code:"CN",name:"China"},{code:"CX",name:"Christmas Island"},{code:"CC",name:"Cocos (Keeling) Islands"},{code:"CO",name:"Colombia"},{code:"KM",name:"Comoros"},{code:"CK",name:"Cook Islands"},{code:"CR",name:"Costa Rica"},{code:"HR",name:"Croatia"},{code:"CU",name:"Cuba"},{code:"CW",name:"Cura\xe7ao"},{code:"CY",name:"Cyprus"},{code:"CZ",name:"Czechia"},{code:"DK",name:"Denmark"},{code:"DJ",name:"Djibouti"},{code:"DM",name:"Dominica"},{code:"DO",name:"Dominican Republic"},{code:"CD",name:"DR Congo"},{code:"EC",name:"Ecuador"},{code:"EG",name:"Egypt"},{code:"SV",name:"El Salvador"},{code:"GQ",name:"Equatorial Guinea"},{code:"ER",name:"Eritrea"},{code:"EE",name:"Estonia"},{code:"SZ",name:"Eswatini"},{code:"ET",name:"Ethiopia"},{code:"FK",name:"Falkland Islands"},{code:"FO",name:"Faroe Islands"},{code:"FJ",name:"Fiji"},{code:"FI",name:"Finland"},{code:"FR",name:"France"},{code:"GF",name:"French Guiana"},{code:"PF",name:"French Polynesia"},{code:"TF",name:"French Southern and Antarctic Lands"},{code:"GA",name:"Gabon"},{code:"GM",name:"Gambia"},{code:"GE",name:"Georgia"},{code:"DE",name:"Germany"},{code:"GH",name:"Ghana"},{code:"GI",name:"Gibraltar"},{code:"GR",name:"Greece"},{code:"GL",name:"Greenland"},{code:"GD",name:"Grenada"},{code:"GP",name:"Guadeloupe"},{code:"GU",name:"Guam"},{code:"GT",name:"Guatemala"},{code:"GG",name:"Guernsey"},{code:"GN",name:"Guinea"},{code:"GW",name:"Guinea-Bissau"},{code:"GY",name:"Guyana"},{code:"HT",name:"Haiti"},{code:"HM",name:"Heard Island and McDonald Islands"},{code:"HN",name:"Honduras"},{code:"HK",name:"Hong Kong"},{code:"HU",name:"Hungary"},{code:"IS",name:"Iceland"},{code:"IN",name:"India"},{code:"ID",name:"Indonesia"},{code:"IR",name:"Iran"},{code:"IQ",name:"Iraq"},{code:"IE",name:"Ireland"},{code:"IM",name:"Isle of Man"},{code:"IL",name:"Israel"},{code:"IT",name:"Italy"},{code:"CI",name:"Ivory Coast"},{code:"JM",name:"Jamaica"},{code:"JP",name:"Japan"},{code:"JE",name:"Jersey"},{code:"JO",name:"Jordan"},{code:"KZ",name:"Kazakhstan"},{code:"KE",name:"Kenya"},{code:"KI",name:"Kiribati"},{code:"XK",name:"Kosovo"},{code:"KW",name:"Kuwait"},{code:"KG",name:"Kyrgyzstan"},{code:"LA",name:"Laos"},{code:"LV",name:"Latvia"},{code:"LB",name:"Lebanon"},{code:"LS",name:"Lesotho"},{code:"LR",name:"Liberia"},{code:"LY",name:"Libya"},{code:"LI",name:"Liechtenstein"},{code:"LT",name:"Lithuania"},{code:"LU",name:"Luxembourg"},{code:"MO",name:"Macau"},{code:"MG",name:"Madagascar"},{code:"MW",name:"Malawi"},{code:"MY",name:"Malaysia"},{code:"MV",name:"Maldives"},{code:"ML",name:"Mali"},{code:"MT",name:"Malta"},{code:"MH",name:"Marshall Islands"},{code:"MQ",name:"Martinique"},{code:"MR",name:"Mauritania"},{code:"MU",name:"Mauritius"},{code:"YT",name:"Mayotte"},{code:"MX",name:"Mexico"},{code:"FM",name:"Micronesia"},{code:"MD",name:"Moldova"},{code:"MC",name:"Monaco"},{code:"MN",name:"Mongolia"},{code:"ME",name:"Montenegro"},{code:"MS",name:"Montserrat"},{code:"MA",name:"Morocco"},{code:"MZ",name:"Mozambique"},{code:"MM",name:"Myanmar"},{code:"NA",name:"Namibia"},{code:"NR",name:"Nauru"},{code:"NP",name:"Nepal"},{code:"NL",name:"Netherlands"},{code:"NC",name:"New Caledonia"},{code:"NZ",name:"New Zealand"},{code:"NI",name:"Nicaragua"},{code:"NE",name:"Niger"},{code:"NG",name:"Nigeria"},{code:"NU",name:"Niue"},{code:"NF",name:"Norfolk Island"},{code:"KP",name:"North Korea"},{code:"MK",name:"North Macedonia"},{code:"MP",name:"Northern Mariana Islands"},{code:"NO",name:"Norway"},{code:"OM",name:"Oman"},{code:"PK",name:"Pakistan"},{code:"PW",name:"Palau"},{code:"PS",name:"Palestine"},{code:"PA",name:"Panama"},{code:"PG",name:"Papua New Guinea"},{code:"PY",name:"Paraguay"},{code:"PE",name:"Peru"},{code:"PH",name:"Philippines"},{code:"PN",name:"Pitcairn Islands"},{code:"PL",name:"Poland"},{code:"PT",name:"Portugal"},{code:"PR",name:"Puerto Rico"},{code:"QA",name:"Qatar"},{code:"CG",name:"Republic of the Congo"},{code:"RE",name:"R\xe9union"},{code:"RO",name:"Romania"},{code:"RU",name:"Russia"},{code:"RW",name:"Rwanda"},{code:"BL",name:"Saint Barth\xe9lemy"},{code:"SH",name:"Saint Helena, Ascension and Tristan da Cunha"},{code:"KN",name:"Saint Kitts and Nevis"},{code:"LC",name:"Saint Lucia"},{code:"MF",name:"Saint Martin"},{code:"PM",name:"Saint Pierre and Miquelon"},{code:"VC",name:"Saint Vincent and the Grenadines"},{code:"WS",name:"Samoa"},{code:"SM",name:"San Marino"},{code:"ST",name:"S\xe3o Tom\xe9 and Pr\xedncipe"},{code:"SA",name:"Saudi Arabia"},{code:"SN",name:"Senegal"},{code:"RS",name:"Serbia"},{code:"SC",name:"Seychelles"}
1,{code:"SL",name:"Sierra Leone"},{code:"SG",name:"Singapore"},{code:"SX",name:"Sint Maarten"},{code:"SK",name:"Slovakia"},{code:"SI",name:"Slovenia"},{code:"SB",name:"Solomon Islands"},{code:"SO",name:"Somalia"},{code:"ZA",name:"South Africa"},{code:"GS",name:"South Georgia"},{code:"KR",name:"South Korea"},{code:"SS",name:"South Sudan"},{code:"ES",name:"Spain"},{code:"LK",name:"Sri Lanka"},{code:"SD",name:"Sudan"},{code:"SR",name:"Suriname"},{code:"SJ",name:"Svalbard and Jan Mayen"},{code:"SE",name:"Sweden"},{code:"CH",name:"Switzerland"},{code:"SY",name:"Syria"},{code:"TW",name:"Taiwan"},{code:"TJ",name:"Tajikistan"},{code:"TZ",name:"Tanzania"},{code:"TH",name:"Thailand"},{code:"TL",name:"Timor-Leste"},{code:"TG",name:"Togo"},{code:"TK",name:"Tokelau"},{code:"TO",name:"Tonga"},{code:"TT",name:"Trinidad and Tobago"},{code:"TN",name:"Tunisia"},{code:"TR",name:"Turkey"},{code:"TM",name:"Turkmenistan"},{code:"TC",name:"Turks and Caicos Islands"},{code:"TV",name:"Tuvalu"},{code:"UG",name:"Uganda"},{code:"UA",name:"Ukraine"},{code:"AE",name:"United Arab Emirates"},{code:"GB",name:"United Kingdom"},{code:"US",name:"United States"},{code:"UM",name:"United States Minor Outlying Islands"},{code:"VI",name:"United States Virgin Islands"},{code:"UY",name:"Uruguay"},{code:"UZ",name:"Uzbekistan"},{code:"VU",name:"Vanuatu"},{code:"VA",name:"Vatican City"},{code:"VE",name:"Venezuela"},{code:"VN",name:"Vietnam"},{code:"WF",name:"Wallis and Futuna"},{code:"EH",name:"Western Sahara"},{code:"YE",name:"Yemen"},{code:"ZM",name:"Zambia"},{code:"ZW",name:"Zimbabwe"}]},59767:(e,t,n)=>{n.d(t,{p:()=>d});var a=n(95155),r=n(12115),o=n(77568),s=n(52171),i=n(82058),l=n(63014),c=n(54774);function d(e){let{countryCode:t,value:n,onChange:d}=e,[u,m]=(0,r.useState)(!1),[p,h]=(0,r.useState)([]),[f,g]=(0,r.useState)(!1),[x,b]=(0,r.useState)(null);(0,r.useEffect)(()=>{if(!t){h([]),b(null);return}let e=!1;return g(!0),b(null),(0,o.I8)(t).then(t=>{e||(h(t),g(!1))}).catch(t=>{e||(b(t instanceof o.Dr?"Couldnât reach the city list. Check your connection.":t instanceof o.MU?"City list took too long to load. Try again.":"Couldnât load cities for this country."),g(!1))}),()=>{e=!0}},[t]);let v=(0,r.useMemo)(()=>[...p].sort((e,t)=>e.name.localeCompare(t.name)),[p]),j=!t||f||!!x,y=t?f?"Loading citiesâ¦":x?"City list unavailable":n||"Select a city":"Pick a country first";return(0,a.jsxs)(i.AM,{open:u,onOpenChange:m,children:[(0,a.jsx)(i.Wv,{asChild:!0,children:(0,a.jsxs)(s.$,{variant:"outline",role:"combobox","aria-expanded":u,"aria-disabled":j,disabled:j,className:"w-full justify-between font-normal",children:[(0,a.jsx)("span",{className:!n||f||x?"text-muted-foreground":"text-foreground",children:y}),(0,a.jsx)(c.default,{name:"IconChevronBottom",size:14})]})}),(0,a.jsx)(i.hl,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:(0,a.jsxs)(l.uB,{children:[(0,a.jsx)(l.G7,{placeholder:"Search citiesâ¦"}),(0,a.jsxs)(l.oI,{children:[(0,a.jsx)(l.xL,{children:"No city found."}),(0,a.jsx)(l.L$,{children:v.map(e=>(0,a.jsxs)(l.h_,{value:"".concat(e.name," ").concat(e.state_code),onSelect:()=>{d(e.name),m(!1)},children:[(0,a.jsx)("span",{className:"flex-1",children:e.name}),e.state_code&&(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:e.state_code}),n===e.name&&(0,a.jsx)(c.default,{name:"IconCheckmark1Small",size:14})]},e.id))})]})]})})]})}},63014:(e,t,n)=>{n.d(t,{G7:()=>c,L$:()=>m,h_:()=>p,oI:()=>d,uB:()=>l,xL:()=>u});var a=n(95155),r=n(12115),o=n(41808),s=n(25016);n(3255);var i=n(43392);let l=r.forwardRef((e,t)=>{let{className:n,...r}=e;return(0,a.jsx)(o.uB,{ref:t,className:(0,s.cn)("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",n),...r})});l.displayName=o.uB.displayName;let c=r.forwardRef((e,t)=>{let{className:n,...r}=e;return(0,a.jsxs)("div",{className:"flex items-center border-b border-border px-3","cmdk-input-wrapper":"",children:[(0,a.jsx)(i.I,{name:"IconMagnifyingGlass",size:16,className:"mr-2 shrink-0 opacity-50"}),(0,a.jsx)(o.uB.Input,{ref:t,className:(0,s.cn)("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",n),...r})]})});c.displayName=o.uB.Input.displayName;let d=r.forwardRef((e,t)=>
1{let{className:n,onWheel:r,...i}=e;return(0,a.jsx)(o.uB.List,{ref:t,onWheel:e=>{e.stopPropagation(),null==r||r(e)},className:(0,s.cn)("max-h-[300px] overflow-y-auto overflow-x-hidden overscroll-contain",n),...i})});d.displayName=o.uB.List.displayName;let u=r.forwardRef((e,t)=>(0,a.jsx)(o.uB.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));u.displayName=o.uB.Empty.displayName;let m=r.forwardRef((e,t)=>{let{className:n,...r}=e;return(0,a.jsx)(o.uB.Group,{ref:t,className:(0,s.cn)("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",n),...r})});m.displayName=o.uB.Group.displayName,r.forwardRef((e,t)=>{let{className:n,...r}=e;return(0,a.jsx)(o.uB.Separator,{ref:t,className:(0,s.cn)("-mx-1 h-px bg-border",n),...r})}).displayName=o.uB.Separator.displayName;let p=r.forwardRef((e,t)=>{let{className:n,...r}=e;return(0,a.jsx)(o.uB.Item,{ref:t,className:(0,s.cn)("relative flex cursor-pointer gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-muted data-[selected=true]:text-foreground-strong data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",n),...r})});p.displayName=o.uB.Item.displayName},64945:(e,t,n)=>{n.d(t,{a:()=>f});var a=n(95155),r=n(12115),o=n(15239),s=n(54263),i=n(25016),l=n(50288),c=n(18720),d=n(12857),u=n(9265),m=n(54774),p=n(1244),h=n(92661);function f(e){let{items:t,organizationId:n,onChange:o}=e,[h,f]=(0,r.useState)(!1),x=(0,r.useRef)(null),b=u.Pw-t.length,v=(0,r.useCallback)(async(e,t)=>{try{let a=await l.u.uploadBuildImage(e,n,e=>{o(n=>n.map(n=>n.id===t?{...n,progress:e}:n))});o(e=>e.map(e=>e.id===t?{...e,s3Key:a.s3Key,src:a.publicUrl,uploadStatus:"done",progress:100}:e))}catch(e){console.error("Gallery upload failed:",e),c.oR.error("Upload failed. Try again."),o(e=>e.map(e=>e.id===t?{...e,uploadStatus:"error"}:e))}},[n,o]),j=(0,r.useCallback)(e=>{let t=Array.from(e).slice(0,b);if(0===t.length)return;let n=t.map(e=>({id:(0,s.A)(),kind:e.type.startsWith("video/")?"video":"image",src:URL.createObjectURL(e),s3Key:"",uploadStatus:"uploading",progress:0}));o(e=>[...e,...n]),n.forEach((e,n)=>{v(t[n],e.id)})},[o,b,v]),y=()=>{var e;return null==(e=x.current)?void 0:e.click()},w=e=>{e.preventDefault(),f(!1),e.dataTransfer.files&&j(e.dataTransfer.files)},N=e=>{e.preventDefault(),f(!0)},C=e=>{e.preventDefault(),f(!1)};return(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("input",{ref:x,type:"file",className:"hidden",accept:"image/*,video/*",multiple:!0,onChange:e=>{e.target.files&&j(e.target.files),e.target.value=""}}),0===t.length?(0,a.jsxs)("div",{onDrop:w,onDragOver:N,onDragLeave:C,className:(0,i.cn)("flex min-h-[200px] flex-col items-center justify-center gap-3 rounded-lg border border-dashed bg-background px-6 py-8 transition-colors",h?"border-primary bg-primary-subtle":"border-border"),children:[(0,a.jsx)(p.Avatar,{size:"lg",children:(0,a.jsx)(p.AvatarFallback,{className:"text-foreground-strong",children:(0,a.jsx)(m.default,{name:"IconImages5",fill:"filled",size:24})})}),(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("p",{className:"text-sm text-foreground-strong",children:"Upload a photo or video"}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Drag pictures or videos here or"," ",(0,a.jsx)("button",{type:"button",onClick:y,className:"text-primary-subtle-foreground underline underline-offset-2",children:"browse"})]})]})]}):(0,a.jsx)("div",{onDrop:w,onDragOver:N,onDragLeave:C,style:{color:"var(--border-subtle)",backgroundImage:"url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25'%3E%3Crect width='100%25' height='100%25' fill='none' stroke-width='1' stroke-dasharray='8 8' rx='8' ry='8'/%3E%3C/svg%3E\")"},className:(0,i.cn)("rounded-lg bg-background p-6 transition-colors",h&&"bg-primary-subtle"),children:(0,a.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[t.map(e=>(0,a.jsx)(g,{item:e,onRemove:()=>(e=>{let n=t.find(t=>
1t.id===e);n&&n.src.startsWith("blob:")&&URL.revokeObjectURL(n.src),o(t=>t.filter(t=>t.id!==e))})(e.id)},e.id)),b>0&&(0,a.jsx)("button",{type:"button",onClick:y,"aria-label":"Add gallery item",className:"flex aspect-square w-full items-center justify-center rounded-lg border border-border bg-background text-muted-foreground transition-colors hover:border-border-emphasis hover:text-foreground",children:(0,a.jsx)(d.I,{name:"IconPlusLarge",size:24})})]})})]})}function g(e){var t;let{item:n,onRemove:r}=e,s="uploading"===n.uploadStatus,i="error"===n.uploadStatus;return(0,a.jsxs)("div",{className:"relative aspect-square w-full overflow-hidden rounded-lg bg-card",children:["video"===n.kind?(0,a.jsx)("video",{src:n.src,className:"h-full w-full object-cover",muted:!0,playsInline:!0,preload:"metadata"}):(0,a.jsx)(o.default,{src:n.src,alt:null!=(t=n.alt)?t:"Build photo",fill:!0,sizes:"(max-width: 768px) 33vw, 220px",className:"object-cover",unoptimized:!0}),"video"===n.kind&&(0,a.jsx)("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center text-white",children:(0,a.jsx)("span",{className:"flex h-9 w-9 items-center justify-center rounded-full bg-black/55",children:(0,a.jsx)(d.I,{name:"IconPlay",size:18})})}),s&&(0,a.jsx)("div",{className:"absolute inset-x-0 bottom-0 h-1 bg-black/40",children:(0,a.jsx)("div",{className:"h-full bg-primary transition-[width] duration-150",style:{width:"".concat(n.progress,"%")}})}),i&&(0,a.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-destructive/80 text-xs text-destructive-foreground",children:"Failed"}),(0,a.jsx)(h.K,{variant:"destructive",size:"xs",onClick:r,"aria-label":"Remove",icon:(0,a.jsx)(d.I,{name:"IconTrashCan",size:12}),className:"absolute right-2 top-2"})]})}},72878:(e,t,n)=>{n.d(t,{Z:()=>i});var a=n(95155),r=n(41407),o=n(18999),s=n(25016);function i(e){let{label:t,progress:n,isComplete:i=!1,className:l}=e,c=Math.min(Math.max(n,0),1),d=(0,r.I)()?{duration:0}:{type:"spring",duration:.5,bounce:0};return(0,a.jsxs)("div",{className:(0,s.cn)("relative min-h-10 w-10 overflow-hidden rounded-lg bg-muted",l),children:[(0,a.jsx)(o.P.div,{"aria-hidden":"true",className:"absolute inset-0 bg-foreground
1/10",style:{transformOrigin:"bottom",willChange:"transform"},initial:{transform:"scaleY(0)"},animate:{transform:"scaleY(".concat(c,")")},transition:d}),(0,a.jsx)(o.P.div,{"aria-hidden":"true",className:"absolute inset-0 bg-primary",style:{transformOrigin:"bottom",willChange:"transform"},initial:{transform:"scaleY(0)"},animate:{transform:"scaleY(".concat(+!!i,")")},transition:d}),(0,a.jsx)("span",{className:(0,s.cn)("absolute inset-0 flex items-center justify-center text-sm font-semibold leading-none tabular-nums transition-colors duration-200",i?"text-primary-foreground":"text-foreground-strong"),children:t})]})}},73543:(e,t,n)=>{n.d(t,{w:()=>o});var a=n(95155),r=n(12857);function o(e){let{manifest:t,projectName:n}=e;return(0,a.jsxs)("div",{className:"flex flex-1 flex-col items-center gap-6",children:[(0,a.jsxs)("header",{className:"flex flex-col items-start gap-3 self-stretch",children:[(0,a.jsx)("h2",{className:"text-2xl font-semibold tracking-tight text-foreground-strong",children:"Your agent is on Tnkr."}),(0,a.jsx)("p",{className:"text-sm leading-relaxed text-foreground",children:"Verification is how we confirm your robot is real, working, and yours. You'll connect it to Tnkr, run the project's setup steps, and calibrate. When you finish, your card unlocks â and you can run your robot in the simulator."})]}),(0,a.jsxs)("div",{className:"flex w-full flex-col self-stretch overflow-hidden rounded-lg border border-border bg-background",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3",children:[(0,a.jsx)("span",{className:"flex h-10 w-10 items-center justify-center rounded-md bg-warning-subtle text-warning-foreground",children:(0,a.jsx)(r.I,{name:"IconCuteRobot",size:20})}),(0,a.jsxs)("div",{className:"flex flex-1 flex-col",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-foreground-strong",children:n}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:[t.steps.length," steps \xb7 ",t.durationEstimate]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 border-t border-border-subtle bg-muted px-4 py-2.5 text-xs text-foreground",children:[(0,a.jsx)(r.I,{name:"IconCircleInfo",size:12,className:"text-muted-foreground"}),(0,a.jsx)("span",{children:t.requirementsSummary})]})]})]})}},82058:(e,t,n)=>{n.d(t,{AM:()=>s,Wv:()=>i,dT:()=>l,hl:()=>c});var a=n(95155);n(12115);var r=n(31138),o=n(25016);function s(e){let{...t}=e;return(0,a.jsx)(r.bL,{"data-slot":"popover",...t})}function i(e){let{...t}=e;return(0,a.jsx)(r.l9,{"data-slot":"popover-trigger",...t})}function l(e){let{...t}=e;return(0,a.jsx)(r.Mz,{"data-slot":"popover-anchor",...t})}function c(e){let{className:t,align:n="center",sideOffset:s=4,...i}=e;return(0,a.jsx)(r.ZL,{children:(0,a.jsx)(r.UC,{"data-slot":"popover-content",align:n,sideOffset:s,className:(0,o.cn)("bg-card text-foreground-strong z-50 w-72 rounded-[var(--radius)] border border-border p-4 shadow-none outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",t),...i})})}},84256:(e,t,n)=>{n.d(t,{u:()=>G});var a=n(95155),r=n(12115),o=n(18720),s=n(3255),i=n(52171),l=n(74369),c=n(28783),d=n(88534),u=n(23037),m=n(99289),p=n(59767),h=n(25016),f=n(64945),g=n(88182),x=n(12857),b=n(82058),v=n(63014),j=n(43392);function y(e){let{placeholder:t="Search...",items:n=[],onSelect:o,className:s,value:i,disabled:l=!1,showSearchIcon:c=!1,isLoading:d=!1,loadingText:u="Loading...",emptyText:m="No items found"}=e,[p,f]=(0,r.useState)(!1),[g,x]=(0,r.useState)(null);return(0,r.useEffect)(()=>{i?x(n.find(e=>e.id===i)||null):x(null)},[i,n]),(0,a.jsxs)(b.AM,{open:p&&!l,onOpenChange:f,children:[(0,a.jsx)(b.Wv,{asChild:!0,children:(0,a.jsx)("button",{type:"button",onClick:()=>{l||f(!0)},disabled:l,className:(0,h.cn)("w-full text-left",s),children:(0,a.jsxs)("div",{className:(0,h.cn)("relative border border-border rounded-lg overflow-hidden transition-colors",l?"opacity-50 cursor-not-allowed":"hover:border-muted-foreground
1/50 cursor-pointer"),children:[(0,a.jsx)("div",{className:(0,h.cn)("w-full pl-3 py-2 bg-transparent text-sm",c?"pr-8":"pr-3"),children:g?(0,a.jsx)("span",{className:"text-foreground",children:g.label}):(0,a.jsx)("span",{className:"text-muted-foreground",children:t})}),c&&(0,a.jsx)(j.I,{name:"IconMagnifyingGlass",size:16,className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-muted-foreground pointer-events-none"})]})})}),(0,a.jsx)(b.hl,{className:"w-[calc(var(--radix-popover-trigger-width)/2)] p-0 bg-background border-border z-[10000]",align:"start",children:(0,a.jsxs)(v.uB,{className:"bg-background",children:[(0,a.jsx)(v.G7,{placeholder:"Search Projects",className:"border-b border-border text-foreground placeholder:text-muted-foreground"}),(0,a.jsx)(v.oI,{className:"max-h-60",children:d?(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2 py-6 text-muted-foreground",children:[(0,a.jsx)(j.I,{name:"IconLoadingCircle",size:16,className:"animate-spin"}),(0,a.jsx)("span",{children:u})]}):0===n.length?(0,a.jsx)(v.xL,{className:"text-muted-foreground py-4",children:m}):(0,a.jsx)(v.L$,{children:n.map(e=>(0,a.jsxs)(v.h_,{value:e.label,onSelect:()=>{var t;x(e),f(!1),null==o||o(e),null==(t=e.onSelect)||t.call(e)},className:"cursor-pointer hover:bg-popover data-[selected=true]:bg-popover flex justify-between py-3 text-foreground",children:[(0,a.jsx)("span",{children:e.label}),(0,a.jsx)(j.I,{name:"IconChevronRight",size:16,className:"text-foreground-disabled"})]},e.id))})})]})})]})}function w(e){let{value:t,onChange:n}=e,[o,s]=(0,r.useState)([]),[i,l]=(0,r.useState)(!0),c=(0,r.useCallback)(async()=>{l(!0);try{let e=await fetch("/api/get-public-projects?limit=50");if(e.ok){let t=await e.json();s(t)}}catch(e){console.error("Failed to load projects:",e)}finally{l(!1)}},[]);(0,r.useEffect)(()=>{c()},[c]);let d=o.map(e=>({id:e.projectId,label:e.projectName}));return(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("span",{className:"text-sm font-medium text-foreground-strong",children:"Project"}),(0,a.jsx)(y,{placeholder:"Pick the project this agent is forâ¦",items:d,onSelect:e=>{var t;let a=o.find(t=>t.projectId===e.id);n({id:e.id,name:e.label,presetId:null!=(t=null==a?void 0:a.supportedRobotPresetId)?t:null})},value:t,isLoading:i,showSearchIcon:!0})]})}var N=n(86917),C=n(9265);function k(e){let t,n=e.name.trim().length>0,a=e.gallery.length>0,r=e.gallery.every(e=>"done"===e.uploadStatus),o=e.description.length>=C.aG,s=e.country.trim().length>0,i=e.city.trim().length>0,l=Math.min(e.description.length/C.aG,1),c=a&&r;return n?a?r?o?s?i||(t="Add a city to continue."):t="Add a country to continue.":t="A bit more â we need at least 80 characters.":t="Wait for uploads to finish.":t="Add a photo or video to continue.":t="Your robot needs a name to continue.",{hasName:n,hasGallery:a,allUploadsDone:r,descriptionMet:o,hasCountry:s,hasCity:i,progress:.2*!!n+.2*l+.2*!!c+.2*!!s+.2*!!i,canContinue:n&&c&&o&&s&&i,disabledReason:t}}function I(e){let{draft:t,organizationId:n,onChange:r,showProjectPicker:o,projectId:s,onProjectChange:i,nameError:l}=e,c=C.aG-t.description.length,{descriptionMet:d}=k(t);return(0,a.jsxs)("div",{className:"flex flex-1 flex-col gap-6",children:[(0,a.jsxs)("header",{className:"flex flex-col gap-2",children:[(0,a.jsx)("h2",{className:"text-xl font-semibold tracking-tight text-foreground-strong",children:"Give your robot a face"}),(0,a.jsx)("p",{className:"text-sm text-foreground",children:"A name, a photo or video, and a few words. This is what people see first."})]}),o&&(0,a.jsx)(w,{value:s,onChange:i}),(0,a.jsxs)(S,{label:"Name",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("span",{className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground",children:(0,a.jsx)(x.I,{name:"IconRobot",size:14})}),(0,a.jsx)(u.p,{placeholder:"e.g. Atlas, Heron, Worker-03",value:t.name,onChange:e=>r({...t,name:e.target.value}),"aria-invalid":!!l||void 0,className:(0,h.cn)("pl-8",l&&"border-destructive focus-visible:ring-destructive/50")})]}),l&&(0,a.jsx)("p",{className:"text-xs text-destructive",children:l})]}),(0,a.jsx)(S,{label:"Description",helper:d?"".concat(t.description.length," characters"):"".concat(c," more characters"),children:(0,a.jsx)(m.T,{placeholder:"What is this robot? What does it do, and what makes it yours?",value:t.description,onChange:e=>r({...t,description:e.target.value}),rows:3})}),(0,a.jsx)(S,{label:"Gallery",helper:"Up to 12 photos or videos.",children:(0,a.jsx)(f.a,{items:t.gallery,organizationId:n,onChange:e=>r(t=>({...t,gallery:"function"==typeof e?e(t.gallery):e}))})}),(0,a.jsx)(S,{label:"Location",helper:"Where this agent was made.",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3 md:flex-row md:gap-2",children:[(0,a.jsx)("div",{className:"md:flex-1",children:(0,a.jsx)(N.G,{value:t.country,onChange:e=>r({...t,country:e,city:""})})}),(0,a.jsx)("div",{className:"md:flex-1",children:(0,a.jsx)(p.p,{countryCode:t.country,value:t.city,onChange:e=>r({...t,city:e})})})]})}),(0,a.jsx)(S,{label:"Tags",helper:"Press Enter to add.",children:(0,a.jsx)(g.F,{tags:t.tags,onChange:e=>r({...t,tags:e})})})]})}function S(e){let{label:t,helper:n,children:r}=e;return(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium text-foreground-strong",children:t}),n&&(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:n})]}),r]})}var A=n(73543),R=n(50771),M=n(99776),P=n(80549),T=n(11854);async function _(e){var t,n;let{draft:a,projectId:r,userId:o,profileId:s}=e,i=await fetch("/api/builds/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project_id:r,user_id:o,profile_id:s,name:a.name.trim(),description:a.description.trim(),country:a.country.trim(),city:a.city.trim(),build_image:null!=(n=null==(t=a.gallery[0])?void 0:t.src)?n:"",gallery:a.gallery.map(e=>({id:e.id,kind:e.kind,src:e.src,s3Key:e.s3Key,alt:e.alt})),tags:a.tags})});if(!i.ok){let e=await i.json().catch(()=>({}));if(409===i.status&&"name_taken"===e.error)throw new T.B(e.message);throw Error(e.message||e.error||"Failed to create agent")}return i.json()}var E=n(92942),B=n(5233),z=n(233),L=n(64774);function G(e){var t;let n,{projectId:u,projectName:m,presetId:p,trigger:h,open:f,onOpenChange:g,onCreated:x}=e,{user:b,profile:v}=(0,l.J)(),{organization:j}=(0,c.Z)(),y=function(){let e=(0,M.jE)();return(0,P.n)({mutationFn:_,onSuccess:()=>
1{e.invalidateQueries({queryKey:["explore","public-builds"]}),e.invalidateQueries({queryKey:["explore","community-builds"]}),e.invalidateQueries({queryKey:["userBuilds"]})}})}(),w=void 0!==f,[N,S]=(0,r.useState)(!1),G=w?f:N,[U,H]=(0,r.useState)(1),[O,F]=(0,r.useState)(C.HT),[D,K]=(0,r.useState)(null!=u?u:""),[V,W]=(0,r.useState)(null!=m?m:""),[$,Y]=(0,r.useState)(null!=p?p:null),[q,J]=(0,r.useState)(null),[Z,X]=(0,r.useState)(null),Q=(0,r.useRef)(null);(0,r.useEffect)(()=>{if(!G||1!==U)return;let e=O.name.trim();if(!e)return void X(null);let t=setTimeout(async()=>{var t;null==(t=Q.current)||t.abort();let n=new AbortController;Q.current=n;try{let t=new URLSearchParams({name:e}),a=await fetch("/api/builds/check-name?".concat(t),{signal:n.signal});if(!a.ok)return;let r=await a.json();if(Q.current!==n)return;!1===r.available?X("You already have an agent with that name."):X(e=>e?null:e)}catch(e){"AbortError"!==e.name&&console.error("check-name failed:",e)}},500);return()=>clearTimeout(t)},[O.name,G,U]),(0,r.useEffect)(()=>{if(!G||!u||void 0!==p)return;let e=!1;return fetch("/api/project/".concat(encodeURIComponent(u))).then(e=>e.ok?e.json():null).then(t=>{var n;!e&&t&&Y(null!=(n=t.supportedRobotPresetId)?n:null)}).catch(e=>console.error("AddBuildDialog: preset fetch failed",e)),()=>{e=!0}},[G,u,p]);let{manifest:ee,loading:et}=(0,z._)($),en=(0,B.E)(null!=ee?ee:z.e),ea=(0,r.useCallback)(()=>{H(1),F(C.HT),K(null!=u?u:""),W(null!=m?m:""),Y(null!=p?p:null),J(null),X(null),en.reset()},[u,m,p,en]),er=e=>{w||S(e),null==g||g(e),e||setTimeout(ea,200)},eo=k(O),es=async()=>{let e=b,t=v;if(!(null==e?void 0:e.id)||!(null==t?void 0:t.id)){let n=await l.J.getState().recoverSession(),a=l.J.getState();if(e=a.user,t=a.profile,!n||!(null==e?void 0:e.id)||!(null==t?void 0:t.id))return o.oR.error("Your session has expired â please sign in again."),null}if(!D)return o.oR.error("Pick a project to continue."),null;try{let n=await y.mutateAsync({draft:O,projectId:D,userId:e.id,profileId:t.id});return null==x||x(),n.id}catch(t){if(console.error("Create build failed:",t),t instanceof T.B)return X(t.message),H(1),null;let e=t instanceof Error?t.message:"Failed to create agent.";return o.oR.error(e),null}},ei=async()=>{let e=await es();e&&(J(e),H(3))},el=async()=>{await es()&&(o.oR.success("Physical agent added â verify when you're ready."),er(!1))},ec=3===U?"3.".concat(en.subStepIndex+1):U,ed=1===U?eo.progress:2===U?ee||et?.5:1:(en.subStepIndex+1)/en.totalSteps,eu=1===U&&eo.canContinue||2===U&&!ee&&!et||3===U&&en.isCurrentStepComplete;if(1===U)n=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.$,{variant:"outline",onClick:()=>er(!1),children:"Cancel"}),(0,a.jsx)(i.$,{variant:"default",onClick:()=>{if(!D)return void o.oR.error("Pick a project to continue.");if(Z)return void o.oR.error(Z);if(!eo.canContinue){var e;o.oR.error(null!=(e=eo.disabledReason)?e:"Fill the required fields to continue.");return}H(2)},children:"Continue"})]});else if(2===U&&et)n=(0,a.jsx)(i.$,{variant:"outline",onClick:()=>er(!1),children:"Cancel"});else if(2===U)n=ee?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.$,{variant:"outline",onClick:el,disabled:y.isPending,children:"Skip"}),(0,a.jsx)(i.$,{variant:"default",onClick:ei,loading:y.isPending,children:"Verify Robot"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.$,{variant:"outline",onClick:()=>er(!1),disabled:y.isPending,children:"Cancel"}),(0,a.jsx)(i.$,{variant:"default",onClick:el,loading:y.isPending,children:"Save agent"})]});else{let e=en.isFinalStep;n=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.$,{variant:"ghost",onClick:()=>er(!1),className:"mr-auto",children:"Save and exit"}),(0,a.jsx)(i.$,{variant:"outline",onClick:()=>{if(0===en.subStepIndex)return void H(2);en.goBack()},children:"Back"}),(0,a.jsx)(i.$,{variant:"default",onClick:e?()=>{null==x||x(),o.oR.success("Verified. Your agent is on Tnkr."),er(!1)}:()=>{en.goNext()},disabled:!en.isCurrentStepComplete,children:e?"Finish":"Continue"})]})}return(0,a.jsxs)(s.lG,{open:G,onOpenChange:er,children:[h&&(0,a.jsx)(s.zM,{asChild:!0,children:h}),(0,a.jsx)(s.Cf,{size:"docked",showCloseButton:!1,children:(0,a.jsxs)(d.v,{title:"Add Your Agent",label:ec,progress:ed,isComplete:eu,onClose:()=>er(!1),footer:n,children:[1===U&&(0,a.jsx)(I,{draft:O,organizationId:null!=(t=null==j?void 0:j.id)?t:"",onChange:e=>{if("function"==typeof e)return void F(e);F(e),Z&&e.name!==O.name&&X(null)},showProjectPicker:!u,projectId:D,onProjectChange:e=>
1{K(e.id),W(e.name),Y(e.presetId)},nameError:Z}),2===U&&(et?(0,a.jsx)("div",{className:"flex flex-1 items-center justify-center py-12",children:(0,a.jsx)(L.y,{})}):ee?(0,a.jsx)(A.w,{manifest:ee,projectName:V||O.name||"your robot"}):(0,a.jsx)(R.s,{projectName:V||O.name||"your robot"})),3===U&&(0,a.jsx)(E.E,{state:en,buildId:null!=q?q:void 0,presetId:$})]})})]})}},86917:(e,t,n)=>{n.d(t,{G:()=>d});var a=n(95155),r=n(12115),o=n(52171),s=n(82058),i=n(63014),l=n(12857),c=n(52315);function d(e){var t;let{value:n,onChange:d}=e,[u,m]=(0,r.useState)(!1),p=c.r.find(e=>e.code===n);return(0,a.jsxs)(s.AM,{open:u,onOpenChange:m,children:[(0,a.jsx)(s.Wv,{asChild:!0,children:(0,a.jsxs)(o.$,{variant:"outline",role:"combobox","aria-expanded":u,className:"w-full justify-between font-normal",children:[(0,a.jsx)("span",{className:p?"text-foreground":"text-muted-foreground",children:null!=(t=null==p?void 0:p.name)?t:"Select a country"}),(0,a.jsx)(l.I,{name:"IconChevronBottom",size:14})]})}),(0,a.jsx)(s.hl,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:(0,a.jsxs)(i.uB,{children:[(0,a.jsx)(i.G7,{placeholder:"Search countriesâ¦"}),(0,a.jsxs)(i.oI,{children:[(0,a.jsx)(i.xL,{children:"No country found."}),(0,a.jsx)(i.L$,{children:c.r.map(e=>(0,a.jsxs)(i.h_,{value:"".concat(e.name," ").concat(e.code),onSelect:()=>{d(e.code),m(!1)},children:[(0,a.jsx)("span",{className:"flex-1",children:e.name}),n===e.code&&(0,a.jsx)(l.I,{name:"IconCheckmark1Small",size:14})]},e.code))})]})]})})]})}},88182:(e,t,n)=>{n.d(t,{F:()=>i});var a=n(95155),r=n(12115),o=n(32964),s=n(12857);function i(e){let{tags:t,onChange:n,placeholder:i="Add a tag"}=e,[l,c]=(0,r.useState)(""),d=e=>{let a=e.trim().toLowerCase();if(a){if(t.includes(a))return void c("");n([...t,a]),c("")}},u=e=>{n(t.filter((t,n)=>n!==e))};return(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 rounded-md border border-border bg-card px-2.5 py-2",children:[t.map((e,t)=>(0,a.jsx)(o.E,{variant:"secondary",size:"default",endIcon:(0,a.jsx)("button",{type:"button",onClick:()=>u(t),"aria-label":"Remove ".concat(e),className:"flex items-center",children:(0,a.jsx)(s.I,{name:"IconCrossMedium",size:10})}),children:e},"".concat(e,"-").concat(t))),(0,a.jsx)("input",{value:l,onChange:e=>c(e.target.value),onKeyDown:e=>{if("Enter"===e.key||","===e.key){e.preventDefault(),d(l);return}"Backspace"===e.key&&""===l&&t.length>0&&(e.preventDefault(),u(t.length-1))},onBlur:()=>l&&d(l),placeholder:0===t.length?i:"",className:"min-w-[120px] flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground"})]})}},88534:(e,t,n)=>{n.d(t,{v:()=>l});var a=n(95155),r=n(92661),o=n(3255),s=n(72878),i=n(12857);function l(e){let{title:t,label:n,progress:l,isComplete:c,footer:d,onClose:u,children:m}=e;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(o.c7,{className:"flex flex-row items-center justify-between gap-2 border-b border-border-subtle px-6 py-4",children:[(0,a.jsx)(o.L3,{className:"text-base font-medium text-foreground-strong",children:t}),(0,a.jsx)(r.K,{variant:"ghost",size:"sm","aria-label":"Close",onClick:u,icon:(0,a.jsx)(i.I,{name:"IconCrossMedium",size:16})})]}),(0,a.jsx)(o.R4,{className:"flex flex-col items-center px-6 py-12",children:(0,a.jsxs)("div",{className:"relative my-auto w-full max-w-2xl",children:[(0,a.jsx)("div",{className:"pointer-events-none absolute bottom-0 right-full top-0 mr-6 hidden lg:block",children:(0,a.jsx)("div",{className:"pointer-events-auto sticky top-0",children:(0,a.jsx)(s.Z,{label:n,progress:l,isComplete:c})})}),(0,a.jsxs)("div",{className:"flex w-full flex-col items-center gap-12 lg:gap-0",children:[(0,a.jsx)("div",{className:"lg:hidden",children:(0,a.jsx)(s.Z,{label:n,progress:l,isComplete:c})}),(0,a.jsx)("div",{className:"w-full",children:m})]})]})}),(0,a.jsx)(o.Es,{className:"justify-end border-t border-border-subtle px-6 py-4 pb-4 sm:justify-end",children:d})]})}},92190:(e,t,n)=>{n.d(t,{XX:()=>p,nn:()=>d,us:()=>u,hJ:()=>x,yB:()=>f,JO:()=>h,f6:()=>g,vY:()=>m});var a=n(95155),r=n(12115),o=n(47650),s=n(20063);let i=[{kind:"agent",matches:e=>/^\/builds\/(?!setup\/)[^/]+\/[^/]+$/.test(e),createAction:{label:"New Agent",intent:"agent"}},{kind:"project",matches:e=>
1/^\/projects\/home\/[^/]+$/.test(e),section:null,icon:"IconRobot",createAction:{label:"New Project",intent:"project"}},{kind:"project",matches:e=>/^\/projects\/hardware-docs\/[^/]+$/.test(e),section:"Hardware",icon:"IconChipSimple",createAction:{label:"New Project",intent:"project"}},{kind:"project",matches:e=>/^\/projects\/central-docs\/[^/]+$/.test(e),section:"Docs",icon:"IconScript",createAction:{label:"New Project",intent:"project"}},{kind:"project",matches:e=>/^\/projects\/file-management\/[^/]+$/.test(e),section:"Files",icon:"IconFolderPaper",createAction:{label:"New Project",intent:"project"}},{kind:"project",matches:e=>/^\/projects\/kit\/[^/]+$/.test(e),section:"Kit",icon:"IconPackage",createAction:{label:"New Project",intent:"project"}},{kind:"project",matches:e=>/^\/projects\/home\/[^/]+\/tips$/.test(e),section:"Tips",icon:"IconLightBulbSimple",createAction:{label:"New Project",intent:"project"}},{kind:"project",matches:e=>/^\/projects\/settings\/[^/]+\/(general|members|git|discord|customization|motion|onshape|integrations(?:\/github)?)$/.test(e),section:"Settings",icon:"IconSettingsSliderHor",settings:!0,createAction:{label:"New Project",intent:"project"}},{kind:"project",matches:e=>/^\/projects\/mods\/[^/]+(?:\/[^/]+)?$/.test(e),section:"Mods",icon:"IconRewrite",workspace:"mods",createAction:{label:"Create Mod",intent:"mod"}},{kind:"project",matches:e=>/^\/projects\/merges\/[^/]+(?:\/(?:[^/]+|review\/[^/]+))?$/.test(e),section:"Merge requests",icon:"IconPullRequestSimple",workspace:"merges",createAction:null}],l=(0,r.createContext)({registration:null,location:null,setRegistration:()=>{},actionPathname:null,setActionPathname:()=>{},actionHost:null,setActionHost:()=>{},titlePathname:null,setTitlePathname:()=>{},titleHost:null,setTitleHost:()=>{},withinProvider:!1});function c(e){var t;let{onChange:n}=e,a=(0,s.usePathname)()||"/",o=(null==(t=(0,s.useSearchParams)())?void 0:t.toString())||"";return(0,r.useEffect)(()=>n({pathname:a,search:o}),[a,o,n]),null}function d(e){let{children:t}=e,[n,o]=(0,r.useState)(null),[s,i]=(0,r.useState)(null),[d,u]=(0,r.useState)(null),[m,p]=(0,r.useState)(null),[h,f]=(0,r.useState)(null),[g,x]=(0,r.useState)(null),b=(0,r.useMemo)(()=>({registration:n,location:s,setRegistration:o,actionPathname:d,setActionPathname:u,actionHost:m,setActionHost:p,titlePathname:h,setTitlePathname:f,titleHost:g,setTitleHost:x,withinProvider:!0}),[n,s,d,m,h,g]);return(0,a.jsxs)(l.Provider,{value:b,children:[(0,a.jsx)(r.Suspense,{fallback:null,children:(0,a.jsx)(c,{onChange:i})}),t]})}function u(e){let{children:t}=e,n=(0,s.usePathname)()||"/",{titlePathname:a,setTitlePathname:i,titleHost:c,withinProvider:d}=(0,r.useContext)(l);return((0,r.useEffect)(()=>(i(n),()=>i(e=>e===n?null:e)),[n,i]),d)?a===n&&c?(0,o.createPortal)(t,c):null:t}function m(){let e=(0,s.usePathname)()||"/",{titlePathname:t,setTitleHost:n}=(0,r.useContext)(l);return{hasSubpageTitle:t===e,setTitleHost:n}}function p(e){let{children:t}=e,n=(0,s.usePathname)()||"/",{actionPathname:a,setActionPathname:i,actionHost:c,withinProvider:d}=(0,r.useContext)(l);return((0,r.useEffect)(()=>(i(n),()=>i(e=>e===n?null:e)),[n,i]),d)?a===n&&c?(0,o.createPortal)(t,c):null:t}function h(){let e=(0,s.usePathname)()||"/",{actionPathname:t,setActionHost:n}=(0,r.useContext)(l);return{hasSubpageActions:t===e,setActionHost:n}}function f(e){let t=(0,s.usePathname)()||"/",{setRegistration:n}=(0,r.useContext)(l),{kind:a,name:o}=e,i="admin-organization"===e.kind?e.organizationId:void 0,c="agent"===e.kind||"order"===e.kind?e.isOwner:void 0,d="agent"===e.kind?e.isAuthenticated:void 0,u="agent"===e.kind||"explore-project"===e.kind?e.projectHref:void 0,m="agent"===e.kind?e.projectName:void 0,p="project"===e.kind||"explore-project"===e.kind?e.projectId:void 0,h="project"===e.kind||"public-project"===e.kind?e.detailName:void 0,f="explore-project"===e.kind?e.preset:void 0,g="public-project"===e.kind||"profile"===e.kind||"article"===e.kind||"order"===e.kind?e.baseHref:void 0;(0,r.useEffect)(()=>{let e="order"===a?{kind:a,name:o,baseHref:g,isOwner:c}:"profile"===a||"article"===a?{kind:a,name:o,baseHref:g}:"admin-organization"===a?{kind:a,name:o,organizationId:i}:"agent"===a?{kind:a,name:o,isOwner:c,isAuthenticated:d,projectHref:u,projectName:m}:"explore-project"===a?{kind:a,name:o,projectId:p,preset:f,projectHref:null!=u?u:void 0}:"public-project"===a?{kind:a,name:o,baseHref:g,detailName:h}:{kind:a,name:o,projectId:p,detailName:h},r={pathname:t,resource:e};return n(n=>{let a=(null==n?void 0:n.resource.kind)==="project"?n.resource:null,o="project"===e.kind?e:null;return(null==n?void 0:n.pathname)===t&&(null==a?void 0:a.projectId)===(null==o?void 0:o.projectId)&&(null==a?void 0:a.detailName)&&!(null==o?void 0:o.detailName)?n:r}),()=>n(e=>e===r?null:e)},[t,a,o,i,c,d,u,m,p,f,g,h,n])}function g(){let e=(0,s.usePathname)()||"/",{registration:t,location:n}=(0,r.useContext)(l);return(null==n?void 0:n.pathname)!==e?null:function(e,t,n){var a,r,o;if("/stars"===e||"/my-orders"===e)return{items:[{label:"Home",href:"/overview",icon:"IconHomeLine"},{label:"/stars"===e?"Stars":"My Orders",href:e}],createAction:null};let s=e.match(/^\/overview\/settings\/(general|members|billing|domain|security|customization|integrations(?:\/(?:github|onshape|discord(?:\/select-guild)?))?)$/);if(s){let e={general:"General",members:"Members",billing:"Billing",domain:"Domain",security:"Security",customization:"Customization",integrations:"Integrations",github:"GitHub",onshape:"Onshape",discord:"Discord","select-guild":"Select server"},t=[{label:"Home",href:"/overview",icon:"IconHomeLine"},{label:"Settings",href:"/overview/settings/general"}],n="/overview/settings";for(let a of s[1].split("/"))n+="/"+a,t.push({label:e[a],href:n});return{items:t,createAction:null}}if(!n)return null;if("article"===n.kind||"order"===n.kind){if(e!==n.baseHref)return null;let t="article"===n.kind?[{label:"Blog",href:"/blog",icon:"IconScript"}]:[{label:"Home",href:n.isOwner?"/overview":"/",icon:"IconHomeLine"}];return"order"===n.kind&&n.isOwner&&t.push({label:"My Orders",href:"/my-orders"}),t.push({label:n.name,href:e}),{items:t,createAction:null}}if("profile"===n.kind){let t=e.slice(n.baseHref.length);if(!e.startsWith(n.baseHref)||!["","/followers","/following"].includes(t))return null;let a=[{label:"Home",href:"/overview",icon:"IconHomeLine"},{label:n.name,href:n.baseHref}];return t&&a.push({label:"/followers"===t?"Followers":"Following",href:e}),{items:a,createAction:null}}if("admin-organization"===n.kind)return e!=="/administration/"+n.organizationId?null:{
1items:[{label:"Administration",href:"/administration",icon:"IconShieldCheck"},{label:n.name,href:e}],createAction:null};if("explore-project"===n.kind){let r="/explore/build/"+n.projectId+"/viewer",o=null==(a=new URLSearchParams(t).get("project"))?void 0:a.trim(),s="/explore/builds"===e&&o===n.projectId;if(!s&&e!==r)return null;let i=[{label:"Explore",href:"/explore",icon:"IconTelescope"}];return s?(i.push({label:n.name,href:n.projectHref||"/projects/published/"+encodeURIComponent(n.projectId)},{label:"Agents",href:"/explore/builds?project="+encodeURIComponent(n.projectId)}),{items:i,createAction:{label:"New Agent",intent:"agent"}}):(n.preset||i.push({label:n.name,href:n.projectHref||"/projects/published/"+encodeURIComponent(n.projectId)}),i.push({label:n.preset?n.name:"Viewer",href:e}),{items:i,createAction:null})}if("public-project"===n.kind){if(e!==n.baseHref&&!e.startsWith(n.baseHref+"/"))return null;let t=e.slice(n.baseHref.length),a=(null==(r=t.match(/^\/(builds|contributors|stargazers|mods|merges|kit)$/))?void 0:r[1])||(null==(o=t.match(/^\/(mods|merges)\/[^/]+$/))?void 0:o[1]);if(t&&!a)return null;let s=[{label:"Explore",href:"/explore",icon:"IconTelescope"},{label:n.name,href:n.baseHref}];if(a){let t=n.baseHref+"/"+a;s.push({label:{builds:"Agents",contributors:"Contributors",stargazers:"Stargazers",mods:"Mods",merges:"Merge requests",kit:"Kit"}[a],href:t}),e!==t&&s.push({label:n.detailName||("mods"===a?"Mod":"Merge request"),href:e})}return{items:s,createAction:{label:"New Project",intent:"project"}}}let l=i.find(t=>t.kind===n.kind&&t.matches(e));if(!l)return null;if("project"===n.kind&&"project"===l.kind){let t="/projects/home/".concat(n.projectId);if("workspace"in l&&"mods"===l.workspace){let t="/projects/mods/".concat(n.projectId);if(e!==t)return{items:[{label:"Mods",href:"/mods",icon:"IconRewrite"},{label:n.detailName||(e==="".concat(t,"/new")?"New mod":"Mod"),href:e,icon:"IconRewrite"}],createAction:null}}let a=[{label:"Projects",href:"/projects",icon:"IconBook"},{label:n.name,href:t,icon:"IconRobot"}];if("settings"in l){let t="/projects/settings/".concat(n.projectId);a.push({label:"Settings",href:"".concat(t,"/general"),icon:"IconSettingsSliderHor"});let r=e.slice(t.length+1);"integrations/github"===r&&a.push({label:"Integrations",href:"".concat(t,"/integrations"),icon:"IconPuzzle"}),a.push({label:{general:"General",members:"Members",git:"Git",discord:"Discord",customization:"Customization",motion:"Motion",onshape:"Onshape",integrations:"Integrations","integrations/github":"GitHub"}[r],href:e,icon:{general:"IconSettingsSliderHor",members:"IconUserGroup",git:"IconGithub",discord:"IconBubble2",customization:"IconBrush",motion:"IconRobot",onshape:"IconBox2",integrations:"IconPuzzle","integrations/github":"IconGithub"}[r]})}else if("workspace"in l){let t="/projects/".concat(l.workspace,"/").concat(n.projectId);if(a.push({label:l.section,href:t,icon:l.icon}),e!==t){let r=e==="".concat(t,"/new")?"mods"===l.workspace?"New mod":"New pull request":e.includes("/review/")?"Review":null,o=n.detailName||r;o&&a.push({label:o,href:e,icon:l.icon})}}else l.section&&a.push({label:l.section,href:e,icon:l.icon});return{items:a,createAction:"workspace"in l&&"mods"===l.workspace?e==="/projects/mods/".concat(n.projectId)?{label:"Create Mod",intent:"mod",href:"/projects/mods/".concat(n.projectId,"/new")}:null:l.createAction}}return"agent"!==n.kind||"agent"!==l.kind?null:{items:function(e){let{isOwner:t,isAuthenticated:n,name:a,href:r}=e;return[...t&&n?[{label:"Agents",href:"/builds",icon:"IconPlugin2"}]:[{label:"Explore",href:"/explore",icon:"IconTelescope"},{label:"Agents",href:"/explore/builds",icon:"IconPlugin2"}],{label:a,href:r,icon:"IconPlugin2"}]}({...n,href:e}),createAction:l.createAction}}(e,n.search,(null==t?void 0:t.pathname)===e?t.resource:void 0)}function x(e){return e}},92942:(e,t,n)=>{n.d(t,{E:()=>T});var a=n(95155),r=n(52171),o=n(12857),s=n(68704),i=n(69170),l=n(25016),c=n(12115),d=n(43392);function u(e){let{text:t,className:n}=e,[o,s]=(0,c.useState)(!1),i=async()=>{await navigator.clipboard.writeText(t),s(!0),setTimeout(()=>s(!1),2e3)};return(0,a.jsx)(r.$,{variant:"ghost",size:"sm",className:(0,l.cn)("size-7 p-0 text-foreground hover:text-foreground-strong",n),onClick:i,"aria-label":o?"Copied":"Copy",children:(0,a.jsxs)("span",{className:"relative size-3.5",children:[(0,a.jsx)(d.I,{name:"IconSquareBehindSquare1",size:16,className:(0,l.cn)("absolute inset-0 size-3.5 transition-opacity",o?"opacity-0":"opacity-100")}),(0,a.jsx)(d.I,{name:"IconCheckmark1",size:16,className:(0,l.cn)("absolute inset-0 size-3.5 transition-opacity",o?"opacity-100":"opacity-0")})]})})}
1function m(e){let{code:t}=e;return(0,a.jsxs)("div",{className:"relative rounded-lg border border-border bg-muted p-4 pr-12",children:[(0,a.jsx)("pre",{className:"overflow-x-auto text-xs text-foreground-strong",children:(0,a.jsx)("code",{children:t})}),(0,a.jsx)(u,{text:t,className:"absolute right-2 top-1/2 -translate-y-1/2"})]})}let p=["http:","https:","mailto:"];function h(e){try{return p.includes(new URL(e,"https://tnkr.ai").protocol)?e:""}catch(e){return""}}let f={warning:"border-warning bg-warning-subtle text-warning-subtle-foreground",note:"border-border bg-muted text-foreground",tip:"border-border bg-muted text-foreground"},g=/^\[!(NOTE|TIP|WARNING)\]\s*/i;function x(){let e=t=>{if(Array.isArray(t.children))for(let o of t.children){if("blockquote"===o.type){var n,a,r;let e=null==(n=o.children)?void 0:n[0],t=null==e||null==(a=e.children)?void 0:a[0];if((null==e?void 0:e.type)==="paragraph"&&(null==t?void 0:t.type)==="text"&&t.value){let n=t.value.match(g);n&&(t.value=t.value.slice(n[0].length),t.value||e.children.shift(),o.data={...null!=(r=o.data)?r:{},hProperties:{className:["manifest-callout","manifest-callout-".concat(n[1].toLowerCase())]}})}}e(o)}};return t=>e(t)}let b={a(e){let{href:t,children:n}=e;return(0,a.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-primary-subtle-foreground underline",children:n})},pre(e){let{children:t}=e;return(0,a.jsx)(m,{code:(function e(t){if(null==t||!1===t||!0===t)return"";if("string"==typeof t||"number"==typeof t)return String(t);if(Array.isArray(t))return t.map(e).join("");if("object"==typeof t&&"props"in t){var n;return e(null==(n=t.props)?void 0:n.children)}return""})(t).replace(/\n$/,"")})},code(e){let{children:t}=e;return(0,a.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 text-xs text-foreground-strong",children:t})},blockquote(e){let{className:t,children:n}=e,r=function(e){var t,n;let a=Array.isArray(e)?e.join(" "):"string"==typeof e?e:"";return a.includes("manifest-callout")&&null!=(n=null==(t=a.match(/manifest-callout-(warning|note|tip)/))?void 0:t[1])?n:null}(t);return r?(0,a.jsx)("div",{className:(0,l.cn)("rounded-lg border px-4 py-3 text-xs [&_strong]:!text-current",f[r]),children:n}):(0,a.jsx)("blockquote",{className:"border-l-2 border-border pl-3 text-sm text-muted-foreground",children:n})}};function v(e){let{body:t}=e;return(0,a.jsx)("div",{className:(0,l.cn)("space-y-3 text-sm text-foreground","[&_ol]:list-decimal [&_ol]:space-y-2 [&_ol]:pl-5","[&_ul]:list-disc [&_ul]:space-y-1 [&_ul]:pl-5","[&_strong]:font-semibold [&_strong]:text-foreground-strong","[&_p]:leading-relaxed"),children:(0,a.jsx)(s.oz,{remarkPlugins:[i.A,x],urlTransform:h,components:b,children:t})})}var j=n(23037),y=n(88579),w=n(65715);async function N(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e6,n=w.D.isConnected;n||await w.D.connect({baudRate:t});try{let t=[];for(let n of e)try{await w.D.readPosition(n)}catch(e){t.push(n)}return{ok:0===t.length,unresponsive:t}}finally{n||await w.D.disconnect().catch(()=>{})}}var C=n(95704);async function k(e,t){if("pi_ws"===e){var n;return S({...t,hostname:null!=(n=t.hostname)?n:""})}if("usb_serial"===e)return I(t);throw Error("Transport not implemented: ".concat(e))}async function I(e){var t,n;if("undefined"==typeof navigator||!("serial"in navigator))return{ok:!1,reason:"unsupported_browser"};let a=null!=(t=e.servoIds)?t:[];if(0===a.length)return{ok:!1,reason:"connection_failed"};let r=null!=(n=e.timeoutMs)?n:3e4,o=new Promise(e=>setTimeout(()=>e("__timeout__"),r));try{let t=await Promise.race([N(a,e.baudRate),o]);if("__timeout__"===t)return{ok:!1,reason:"timeout"};return t.ok?{ok:!0}:{ok:!1,reason:"motor_unresponsive"}}catch(e){return{ok:!1,reason:"connection_failed"}}}async function S(e){var t,n;let a=new y.g(null!=(t=e.hostname)?t:"",8e3),r=null!=(n=e.timeoutMs)?n:3e4,o=new Promise(e=>setTimeout(()=>e("__timeout__"),r)),s=a.ping(),i=await Promise.race([s,o]);if("__timeout__"===i)return{ok:!1,reason:"timeout"};if(!i.reachable)return{ok:!1,reason:"unreachable"};let l="true"===C.env.NEXT_PUBLIC_ALLOW_NON_PI_VERIFICATION;return i.isPi||l?{ok:!0}:{ok:!1,reason:"not_tnkr_runtime"}}
1var A=n(88605),R=n(69671);let M={unreachable:"Couldn't reach your robot. Check the hostname and that it's powered on.",not_tnkr_runtime:"Reached that address, but the Tnkr runtime isn't responding. Run the setup script on your Pi.",timeout:"Your robot took too long to respond. Check the connection.",unsupported_browser:"Connecting over USB needs Chrome, Edge, or Opera. Open this page in one of those.",connection_failed:"Couldn't open the USB connection. Plug the robot in, then click Connect and pick its port.",motor_unresponsive:"Connected, but one or more motors didn't respond. Check the wiring and power, then try again.",save_failed:"Connected to your robot but couldn't save. Try again.",missing_build_id:"Something went wrong. Close and reopen this dialog."},P={markdown:function(e){var t;let{step:n,onComplete:s,onAdvance:i,isCompleted:l}=e;return(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)("header",{className:"flex flex-col gap-2",children:[(0,a.jsx)("h2",{className:"text-xl font-semibold tracking-tight text-foreground-strong",children:n.title}),(0,a.jsx)("p",{className:"text-sm text-foreground",children:n.purpose})]}),(0,a.jsx)(v,{body:n.body}),(0,a.jsx)("div",{className:"flex justify-start pt-2",children:(0,a.jsx)(r.$,{variant:l?"secondary":"default",onClick:()=>{l||(s(),null==i||i())},disabled:l,startIcon:l?(0,a.jsx)(o.I,{name:"IconCheckmark1Small",size:14}):void 0,children:l?"Done":null!=(t=n.confirmLabel)?t:"Done"})})]})},probe:function(e){var t,n;let{step:s,onComplete:i,isCompleted:l,buildId:d,presetId:u}=e,m="usb_serial"===s.transport,p=(0,c.useMemo)(()=>{var e,t,n;return m&&u&&null!=(n=null==(t=(0,R.s)(u))||null==(e=t.joints)?void 0:e.list.map(e=>e.servoId))?n:[]},[m,u]),h=m&&"undefined"!=typeof navigator&&!("serial"in navigator),f=null!=(n=null==(t=s.confirm.options)?void 0:t.defaultHostname)?n:"",[g,x]=(0,c.useState)(f),[b,v]=(0,c.useState)(l?"success":"idle"),[y,w]=(0,c.useState)(null),N=async()=>{var e,t,n;v("probing"),w(null);let a=m?await k("usb_serial",{servoIds:p,baudRate:null==(e=s.confirm.options)?void 0:e.baudRate,timeoutMs:s.timeoutMs}):await k("pi_ws",{hostname:g,endpoint:null==(t=s.confirm.options)?void 0:t.endpoint,timeoutMs:s.timeoutMs});if(!a.ok){v("failure"),w(null!=(n=a.reason)?n:"unreachable");return}if(m||(0,A.Ro)(g),!d){v("failure"),w("missing_build_id");return}try{if(!(await fetch("/api/builds/".concat(d,"/verify"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(m?{}:{hostname:g})})).ok){v("failure"),w("save_failed");return}}catch(e){v("failure"),w("save_failed");return}v("success"),i()},C="probing"===b,I="success"===b,S="failure"===b,P=I||h||(m?0===p.length:0===g.trim().length),T=m?"Connect & verify":"Probe now";return(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsxs)("header",{className:"flex flex-col gap-2",children:[(0,a.jsx)("h2",{className:"text-xl font-semibold tracking-tight text-foreground-strong",children:s.title}),(0,a.jsx)("p",{className:"text-sm text-foreground",children:s.purpose})]}),m?(0,a.jsxs)("div",{className:"rounded-lg bg-muted px-4 py-3 text-xs text-foreground",children:["Plug your robot into this computer with a USB cable, then click"," ",(0,a.jsx)("strong",{className:"text-foreground-strong",children:"Connect & verify"}),". Your browser will ask which device to use â pick your robot's port."]}):(0,a.jsx)("div",{className:"flex flex-col gap-3",children:(0,a.jsxs)("label",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("span",{className:"text-sm font-medium text-foreground-strong",children:"Hostname or IP address"}),(0,a.jsx)(j.p,{value:g,onChange:e=>x(e.target.value),placeholder:"yourhostname.local",disabled:C||I})]})}),(0,a.jsxs)("div",{className:"flex items-center gap-3 pt-2",children:[(0,a.jsx)(r.$,{variant:I?"secondary":S?"destructive-outline":"default",onClick:N,loading:C,disabled:P,startIcon:I?(0,a.jsx)(o.I,{name:"IconCheckmark1Small",size:14}):S?(0,a.jsx)(o.I,{name:"IconExclamationTriangle",size:14}):void 0,children:I?"Verified":S?"Try again":C?"Connectingâ¦":T}),I&&(0,a.jsx)("p",{className:"text-sm text-success-subtle-foreground",children:"Your robot is on Tnkr. Click Finish to save."}),h&&(0,a.jsx)("p",{className:"text-sm text-destructive-subtle-foreground",children:M.unsupported_browser}),S&&y&&!h&&(0,a.jsx)("p",{className:"text-sm text-destructive-subtle-foreground",children:M[y]})]})]})}};function T(e){let{state:t,buildId:n,presetId:r}=e,{currentStep:o,completeCurrentStep:s,capturedValues:i,isCurrentStepComplete:l,goNext:c}=t,d=P[o.type];return d?(0,a.jsx)(d,{step:o,capturedValues:i,onComplete:s,onAdvance:c,isCompleted:l,buildId:n,presetId:r}):(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-border bg-card p-6 text-sm",children:[(0,a.jsx)("p",{className:"font-medium text-foreground-strong",children:"We don't support this step type yet"}),(0,a.jsxs)("p",{className:"text-foreground",children:["Step ",(0,a.jsx)("code",{className:"rounded bg-muted px-1 py-0.5",children:o.id})," uses type"," ",(0,a.jsx)("code",{className:"rounded bg-muted px-1 py-0.5",children:o.type}),", which the wizard can't render in this build."]})]})}}}]);
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.