"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useActivateExample=useActivateExample;const react_1=require("react"),jotai_1=require("jotai"),models_1=require("../models"),operation_1=require("../jotai/operation"),app_1=require("../jotai/app");function useActivateExample(e){const i=(0,jotai_1.useSetAtom)((0,operation_1.operationStore)((null==e?void 0:e.operation.pointer)||"no_operation_pointer")),o=(0,jotai_1.useAtomValue)(app_1.activeMimeNameAtom),t=e?(0,models_1.getActiveMediaType)(e,o):void 0;return(0,react_1.useCallback)((e=>{var o,a,l,r,n,s,u;if(t)if(t.examples&&(null===(o=t.schema)||void 0===o?void 0:o.oneOf)&&Object.keys(t.examples).includes(e)){const o=null===(l=null===(a=t.schema)||void 0===a?void 0:a.oneOf)||void 0===l?void 0:l.findIndex((i=>i.title===e));i(-1===o?{activeExampleName:e,requestValues:{}}:{activeOneOf:{[(null===(r=t.schema)||void 0===r?void 0:r.pointer)||""]:o},activeExampleName:null===(u=null===(s=null===(n=t.schema)||void 0===n?void 0:n.oneOf)||void 0===s?void 0:s[o])||void 0===u?void 0:u.title,requestValues:{}})}else i({activeExampleName:e,requestValues:{}})}),[t,i])}
//# sourceMappingURL=useActivateExample.js.map