1import{n as e,t}from"./runtime-QtgwY_nV.js";function n(t=typeof window<`u`?window.location.host:``){let n=e(`CODER_REMOTE_DEV_PLATFORM_BASE_DOMAIN`);if(!n)return!1;let r=t.split(`:`)[0].toLowerCase(),i=n.toLowerCase();return r===i||r.endsWith(`.${i}`)}var r=`preview`,i=`__b44_preview_target`;function a(e=typeof window<`u`?window.location.host:``,t=typeof window<`u`?window.location.protocol:`https:`){if(!n(e))return null;let i=e.indexOf(`.`);if(i<0)return null;let a=e.slice(0,i),o=e.slice(i),s=a.split(`--`);return s.length<2?null:(s[0]=r,`${t}//${s.join(`--`)}${o}`)}function o(e=typeof window<`u`?window.location.search:``,t=typeof window<`u`?window.location.host:``){if(!n(t))return null;let r=new URLSearchParams(e).get(i);return!r||r.includes(`--`)||!/^[a-z0-9-]+\.localhost:\d+$/i.test(r)?null:r}function s(e,t=typeof window<`u`?window.location.host:``,n=typeof window<`u`?window.location.protocol:`https:`){if(!e)return e;let r=a(t,n);if(!r)return e;let o;try{o=new URL(e)}catch{return e}try{let e=new URL(o.pathname,r);return e.search=o.search,e.hash=o.hash,e.searchParams.set(i,o.host),e.searchParams.has(`server_url`)&&e.searchParams.set(`server_url`,r),e.toString()}catch{return e}}function c(e,t=typeof window<`u`?window.location.host:``,r=typeof window<`u`?window.location.protocol:`https:`){if(!e||!n(t))return e;let a;try{a=new URL(e)}catch{return e}try{let e=new URL(`/`,`${r}//${t}`);return e.searchParams.set(i,a.host),e.toString()}catch{return e}}var l={SUPERAGENT:`/superagent`,CREATE_SUPERAGENT:`/create-superagent`,SUPERAGENT_ONBOARDING:`/superagent-onboarding`,CLONE_SUPERAGENT:`/clone-superagent`,CLONE_SUPERAGENT_TEMPLATE:`/clone-superagent-template`,COLONY:`/colony`,WELCOME:`/welcome`},u={live:`s`,app:`a`,preview:`v`,share:`h`,pentest:`t`,sandbox:`l`,checkpoint:`c`,commit:`g`,branch:`b`},d=`0123456789abcdefghijklmnopqrstuv`,f=`0123456789abcdefghijklmnopqrstuvwxyz-_`;function p(e){let t=1n;for(let n of e)t=t*38n+BigInt(f.indexOf(n));return t.toString(36)}function m(e){if(!/^[0-9a-z]{1,63}$/.test(e))throw Error(`Invalid compact slug`);let t=0n;for(let n of e)t=t*36n+BigInt(parseInt(n,36));let n=``;for(;t>1n;)n=f[Number(t%38n)]+n,t/=38n;if(t!==1n)throw Error(`Invalid compact slug`);return n}function h(e,t=24){if(!RegExp(`^[0-9a-f]{${t}}$`).test(e))throw Error(`Invalid hexadecimal ID`);let n=0,r=0,i=``;for(let t=0;t<e.length;t+=2)for(r=r<<8|parseInt(e.slice(t,t+2),16),n+=8;n>=5;)n-=5,i+=d[r>>>n&31];return n&&(i+=d[r<<5-n&31]),i}function g(e,t=24){let n=0,r=0,i=``;for(let t of e){let e=d.indexOf(t);if(e<0)throw Error(`Invalid compact ID`);r=r<<5|e,n+=5,n>=8&&(n-=8,i+=(r>>>n&255).toString(16).padStart(2,`0`))}if(h(i,t)!==e)throw Error(`Noncanonical compact ID`);return i}function _(e,t,n){if(!n)return`${e.kind===`checkpoint`||e.kind===`commit`?`${e.kind}--${e.identity}--${e.revision}`:e.kind===`branch`?`preview--${e.identity}--b-${e.revision}`:`${e.kind===`live`?``:e.kind===`sandbox`?`preview-sandbox--`:`${e.kind}--`}${e.identity}`}.${t}`;let r=e.identity,i=u[e.kind];if(e.kind===`checkpoint`||e.kind===`commit`)r=`${h(e.identity)}-${h(e.revision,e.kind===`commit`?28:24)}`;else if(e.kind===`branch`||e.kind===`sandbox`){let[t,n=``]=`revision`in e?[e.identity,e.revision]:e.identity.split(`--b-`);if((e.kind===`branch`||n)&&!/^[0-9a-f]{7}$/.test(n))throw Error(`Invalid branch hash`);r=`${h(t)}${n?`-${n}`:``}`}else{if(!/^[a-z0-9_][a-z0-9_-]{0,62}$/.test(r))throw Error(`Invalid slug`);r.includes(`_`)&&(r=p(r),i+=`x`)}let a=`${r}-${i}-p${n.pr_number}`;if(a.length>63){if(t)return _(e,t);throw Error(`DNS label too long`)}return`${a}.${n.namespace}`}function v(e,t){if(!t||!e.endsWith(`.${t.namespace}`))return null;let n=e.slice(0,-(t.namespace.length+1)).split(`-`);if(n.pop()!==`p${t.pr_number}`)return null;let r=n.pop(),i=/^[savht]x$/.test(r??``),a=Object.keys(u).find(e=>u[e]===(i?r[0]:r));if(!a)return null;try{let r;if(a===`checkpoint`||a===`commit`||a===`branch`||a===`sandbox`){let e=g(n[0]);r=a===`checkpoint`||a===`commit`?{kind:a,identity:e,revision:g(n[1],a===`commit`?28:24)}:a===`branch`?{kind:a,identity:e,revision:n[1]}:{kind:a,identity:`${e}${n[1]?`--b-${n[1]}`:``}`}}else r={kind:a,identity:i?m(n.join(`-`)):n.join(`-`)};return _(r,``,t)===e?r:null}catch{return null}}function y(e,t,n){let r=e.replace(/^https?:\/\//,``),i=v(r,n),a=`.${i?.kind===`live`?n.namespace:t}`,o=r.endsWith(a)?r.slice(0,-a.length):r;return{label:o,suffix:r.endsWith(a)?a:``,slug:i?.kind===`live`?i.identity:o}}function b(){return window.__APP_CONFIG__?.FLAT_PREVIEW_HOSTS}function x(e,t){return _(e,t,b())}function S(e,t){return y(e,t,b())}function C(e=window.location.hostname){let t=v(e,b());if(t?.kind===`checkpoint`)return t.revision;if(t?.kind===`preview`||t?.kind===`branch`)return`preview`;if(e.startsWith(`checkpoint--`)){let t=e.split(`--`);if(t.length>=3)return t[2].split(`.`)[0]}return e.startsWith(`preview--`)?`preview`:`prod`}function w(t){if(!t)return!1;try{let n=new URL(t),r=n.host,i=v(r,b());return i&&i.kind!==`pentest`&&n.protocol===`https:`?!0:[e(`SDK_BACKEND_URL`),e(`APPS_BASE_DOMAIN`)].some(e=>{if(!e)return!1;let t=e.includes(`://`)?new URL(e).host:e;return r===t||r.endsWith(`.${t}`)})}catch{return!1}}function T(){let e=O();return new URL(e).host}function E(e){return/^docker-pr-\d+\.velino\.org(?::\d+)?$/.test(e)||/^pr-\d+\.velino\.org(?::\d+)?$/.test(e)}function D(){return e(`APPS_BASE_DOMAIN`)||`base44.app`}function O(){return e(`PLATFORM_URL`)||`https://app.base44.com`}var k=`https://app.base44.com`;function A(){return O().replace(`://backoffice.`,`://app.`)}function j(){return e(`SUPERAGENT_PLATFORM_URL`).trim().replace(/^https?:\/\//i,``).split(/[:/]/)[0].toLowerCase()}function M(e){if(e===T())return!0;let t=j();return t&&e.split(`:`)[0].toLowerCase()===t?!0:n(e)?!o():E(e)}function N(e,t,n){return`${e}/${n===`user_agent`?l.SUPERAGENT.slice(1):`apps`}/${t}`}function P(e,n){return N(t(),e,n)}function F(e,t){return t===`user_agent`?`${l.SUPERAGENT}/${e}`:`/apps/${e}/editor/preview`}function I(e){return W({kind:`live`,identity:e.slug})}function L(e){return U({kind:`live`,identity:e.slug})}function R(e){return S(e,D())}function z(){return L({slug:`app`}).slice(3)}function B(e,t){return W({kind:`checkpoint`,identity:e.id,revision:t.id})}function V(e){return W({kind:`preview`,identity:e.slug})}function H(e){return W({kind:`share`,identity:e.slug})}function U(e){return x(e,D())}function W(e){let t=U(e);return`${G(t.slice(t.indexOf(`.`)+1))}://${t}`}function G(e){return e.includes(`localhost`)||e.includes(`127.0.0.1`)?`http`:`https`}var K=()=>n()?window.location.origin:e(`BACKEND_URL`)||O(),q=()=>n()?window.location.origin:e(`WS_BACKEND_URL`);function J(){return`/api`}function Y(){return J()}export{w as C,c as D,n as E,s as O,C as S,o as T,T as _,k as a,M as b,F as c,R as d,z as f,j as g,D as h,q as i,V as l,H as m,Y as n,P as o,I as p,K as r,B as s,J as t,L as u,O as v,l as w,E as x,A as y};
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.