import{r as e}from"./rolldown-runtime-DCMCV6zW.js";import{E as t,Tt as n,wt as r}from"./vendor-vue-core-D3IvUUeM.js";import{r as i,t as a}from"./types-0oh-UGWL.js";import{n as o,r as s}from"./remoteConfig-CNDr9CtS.js";import{Ot as c,r as l}from"./api-3C7_IVZO.js";import{o as u}from"./i18n-DjEVEIh2.js";let d=function(e){return e.SUPPORTS_PREVIEW_METADATA=`supports_preview_metadata`,e.MAX_UPLOAD_SIZE=`max_upload_size`,e.MANAGER_SUPPORTS_V4=`extension.manager.supports_v4`,e.MODEL_UPLOAD_BUTTON_ENABLED=`model_upload_button_enabled`,e.ASSET_RENAME_ENABLED=`asset_rename_enabled`,e.PRIVATE_MODELS_ENABLED=`private_models_enabled`,e.ONBOARDING_SURVEY_ENABLED=`onboarding_survey_enabled`,e.LINEAR_TOGGLE_ENABLED=`linear_toggle_enabled`,e.TEAM_WORKSPACES_ENABLED=`team_workspaces_enabled`,e.USER_SECRETS_ENABLED=`user_secrets_enabled`,e}({});function useFeatureFlags(){let e=r({get supportsPreviewMetadata(){return l.getServerFeature(d.SUPPORTS_PREVIEW_METADATA)},get maxUploadSize(){return l.getServerFeature(d.MAX_UPLOAD_SIZE)},get supportsManagerV4(){return l.getServerFeature(d.MANAGER_SUPPORTS_V4)},get modelUploadButtonEnabled(){return s.value.model_upload_button_enabled??l.getServerFeature(d.MODEL_UPLOAD_BUTTON_ENABLED,!1)},get assetRenameEnabled(){return s.value.asset_rename_enabled??l.getServerFeature(d.ASSET_RENAME_ENABLED,!1)},get privateModelsEnabled(){return s.value.private_models_enabled??l.getServerFeature(d.PRIVATE_MODELS_ENABLED,!1)},get onboardingSurveyEnabled(){return s.value.onboarding_survey_enabled??l.getServerFeature(d.ONBOARDING_SURVEY_ENABLED,!0)},get linearToggleEnabled(){return!0},get teamWorkspacesEnabled(){return!a||!o.value?!1:s.value.team_workspaces_enabled??l.getServerFeature(d.TEAM_WORKSPACES_ENABLED,!1)},get userSecretsEnabled(){return s.value.user_secrets_enabled??l.getServerFeature(d.USER_SECRETS_ENABLED,!1)}}),featureFlag=(e,n)=>t(()=>l.getServerFeature(e,n));return{flags:n(e),featureFlag}}function useErrorHandling(){let e=c(),toastErrorHandler=t=>{e.add({severity:`error`,summary:u(`g.error`),detail:t instanceof Error?t.message:u(`g.unknownError`)}),console.error(t)},wrapWithErrorHandling=(e,t,n)=>(...r)=>{try{return e(...r)}catch(e){(t??toastErrorHandler)(e)}finally{n?.()}},wrapWithErrorHandlingAsync=(e,t,n,r=[])=>async(...i)=>{try{return await e(...i)}catch(n){for(let t of r)if(t.shouldHandle(n))try{await t.recover(n,e,i);return}catch(e){console.error(`Recovery strategy failed:`,e)}(t??toastErrorHandler)(n)}finally{n?.()}};return{wrapWithErrorHandling,wrapWithErrorHandlingAsync,toastErrorHandler}}export{useFeatureFlags as n,useErrorHandling as t};
//# sourceMappingURL=useErrorHandling-CBX3YQ5l.js.map