o=e.featureToggles.markdownPlusAvoidDuplicatedIdCounter?e.getIdBasedOnIdMap(e,"layoutSection",t.attrs):`id-${e.idCounter++}`;e.idMap[o]={type:"layoutSection",attributes:t.attrs},e.write(`<custom data-type="layoutSection_open" data-id="${o}" />

`);for(let o=0;o<t.childCount;o++){let n=t.child(o);try{e.render(n,t,o,{skipFallback:!0})}catch(o){e.updateFallbackState(o,t),e.nodes.fallback.serialize({state:e,node:t,parent:a,index:r})}}e.write(`<custom data-type="layoutSection_close" />

`)});else{e.updateNonErrorFallbackState(t);for(let a=0;a<t.childCount;a++){let r=t.child(a);e.render(r,t,a)}}},support:"preview"},layoutColumn:{serialize({state:e,node:t,parent:a,index:r}){if(e.featureToggles.markdownPlus&&e.featureToggles.markdownPlusAddComplexNodes){let o=e.featureToggles.markdownPlusAvoidDuplicatedIdCounter?e.getIdBasedOnIdMap(e,"layoutColumn",t.attrs):`id-${e.idCounter++}`;e.idMap[o]={type:"layoutColumn",attributes:t.attrs},e.write(`<custom data-type="layoutColumn_open" data-id="${o}" />

`);for(let o=0;o<t.childCount;o++){let n=t.child(o);try{e.render(n,t,o,{skipFallback:!0})}catch(o){e.updateFallbackState(o,t),e.nodes.fallback.serialize({state:e,node:t,parent:a,index:r})}}e.write(`<custom data-type="layoutColumn_close" />

`)}else{e.updateNonErrorFallbackState(t);for(let a=0;a<t.childCount;a++){let r=t.child(a);e.render(r,t,a)}}},support:"preview"},expand:{serialize({state:e,node:t,parent:a,index:r}){if(e.featureToggles.markdownPlus&&e.featureToggles.markdownPlusAddComplexNodes)e.addBlockMarks(e,t,()=>{let o=e.featureToggles.markdownPlusAvoidDuplicatedIdCounter?e.getIdBasedOnIdMap(e,"expand",t.attrs):`id-${e.idCounter++}`;e.idMap[o]={type:"expand",attributes:t.attrs},e.write(`<custom data-type="expand_open" data-id="${o}" />

`);for(let o=0;o<t.childCount;o++){let n=t.child(o);try{e.render(n,t,o,{skipFallback:!0})}catch(o){e.updateFallbackState(o,t),e.nodes.fallback.serialize({state:e,node:t,parent:a,index:r})}}e.write(`<custom data-type="expand_close" />

`)});else{e.updateNonErrorFallbackState(t);for(let a=0;a<t.childCount;a++){let r=t.child(a);e.render(r,t,a)}}},support:"preview"},nestedExpand:{serialize({state:e,node:t,parent:a,index:r}){if(e.featureToggles.markdownPlus&&e.featureToggles.markdownPlusAddComplexNodes){let o=e.featureToggles.markdownPlusAvoidDuplicatedIdCounter?e.getIdBasedOnIdMap(e,"nestedExpand",t.attrs):`id-${e.idCounter++}`;e.idMap[o]={type:"nestedExpand",attributes:t.attrs},e.write(`<custom data-type="nestedExpand_open" data-id="${o}" />

`);for(let o=0;o<t.childCount;o++){let n=t.child(o);try{e.render(n,t,o,{skipFallback:!0})}catch(o){e.updateFallbackState(o,t),e.nodes.fallback.serialize({state:e,node:t,parent:a,index:r})}}e.write(`<custom data-type="nestedExpand_close" />

`)}else{e.updateNonErrorFallbackState(t);for(let a=0;a<t.childCount;a++){let r=t.child(a);e.render(r,t,a)}}},support:"preview"},panel:{serialize({state:e,node:t,parent:a,index:r}){if(e.featureToggles.markdownPlus&&e.featureToggles.markdownPlusPanels){let o=e.featureToggles.markdownPlusAvoidDuplicatedIdCounter?e.getIdBasedOnIdMap(e,"panel",t.attrs):`id-${e.idCounter++}`;e.idMap[o]={type:"panel",attributes:t.attrs},e.write(`<custom data-type="panel_open" data-id="${o}" />

`);for(let o=0;o<t.childCount;o++){let n=t.child(o);try{e.render(n,t,o,{skipFallback:!0})}catch(o){e.updateFallbackState(o,t),e.nodes.fallback.serialize({state:e,node:t,parent:a,index:r})}}e.write(`<custom data-type="panel_close" />

`)}else{e.updateNonErrorFallbackState(t);for(let a=0;a<t.childCount;a++){let r=t.child(a);e.render(r,t,a)}}},support:"custom"},blockCard:{serialize({state:e,node:t}){e.write(`[${t.attrs.url}](${t.attrs.url})`)},support:"full"},embedCard:{serialize({state:e,node:t}){e.write(`[${t.attrs.url}](${t.attrs.url})`)},support:"full"},decisionList:{serialize({state:e,node:t}){if(e.featureToggles.markdownPlus&&e.featureToggles.markdownPlusDecisions){let a=e.featureToggles.markdownPlusAvoidDuplicatedIdCounter?e.getIdBasedOnIdMap(e,"decisionList",t.attrs):`id-${e.idCounter++}`;e.idMap[a]={type:"decisionList",attributes:t.attrs},e.write(`<custom data-type="decisionList_open" data-id="${a}" />

`);for(let a=0;a<t.childCount;a++){let r=t.child(a);e.render(r,t,a)}e.write(`<custom data-type="decisionList_close" />

`)}else{for(let a=0;a<t.childCount;a++){let r=t.child(a);e.render(r,t,a)}e.write(`

`)}},support:"custom"},decisionItem:{serialize({state:e,node:t,parent:a,index:r}){if(e.featureToggles.markdownPlus&&e.featureToggles.markdownPlusDecisions){let o=e.featureToggles.markdownPlusAvoidDuplicatedIdCounter?e.getIdBasedOnIdMap(e,"decisionItem",t.attrs):`id-${e.idCounter++}`;e.idMap[o]={type:"decisionItem",attributes:t.attrs},e.write(`<custom data-type="decisionItem_open" data-id="${o}" />

`);for(let o=0;o<t.childCount;o++){let n=t.child(o);try{e.render(n,t,o,{skipFallback:!0})}catch(o){e.updateFallbackState(o,t),e.nodes.fallback.serialize({state:e,node:t,parent:a,index:r})}}e.write(`

<custom data-type="decisionItem_close" />

`)}else for(let a=0;a<t.childCount;a++){let r=t.child(a);e.render(r,t,a)}},support:"custom"},extension:{serialize({state:e,node:t}){if(e.featureToggles.markdownPlus&&e.featureToggles.markdownPlusExtensions){let a=e.featureToggles.markdownPlusAvoidDuplicatedIdCounter?e.getIdBasedOnIdMap(e,"extension",t.attrs):`id-${e.idCounter++}`;e.idMap[a]={type:"extension",attributes:t.attrs},e.write(`<custom data-type="extension" data-id="${a}" />

`)}},support:"custom"},inlineExtension:{serialize({state:e,node:t}){if(e.featureToggles.markdownPlus&&e.featureToggles.markdownPlusExtensions){let a=e.featureToggles.markdownPlusAvoidDuplicatedIdCounter?e.getIdBasedOnIdMap(e,"inlineExtension",t.attrs):`id-${e.idCounter++}`;e.idMap[a]={type:"inlineExtension",attributes:t.attrs},e.write(`<custom data-type="inlineExtension" data-id="${a}"></custom>`)}},support:"custom"},bodiedExtension:{serialize({state:e,node:t,parent:a,index:r}){if(e.featureToggles.markdownPlus&&e.featureToggles.markdownPlusExtensions){let o=e.featureToggles.markdownPlusAvoidDuplicatedIdCounter?e.getIdBasedOnIdMap(e,"bodiedExtension",t.attrs):`id-${e.idCounter++}`;e.idMap[o]={type:"bodiedExtension",attributes:t.attrs},e.write(`<custom data-type="bodiedExtension_open" data-id="${o}" />

`);for(let o=0;o<t.childCount;o++){let n=t.child(o);try{e.render(n,t,o,{skipFallback:!0})}catch(o){e.updateFallbackState(o,t),e.nodes.fallback.serialize({state:e,node:t,parent:a,index:r})}}e.write(`<custom data-type="bodiedExtension_close" />

`)}else for(let a=0;a<t.childCount;a++){let r=t.child(a);e.render(r,t,a)}},support:"custom"},fallback:{serialize({state:e,node:t}){t.isBlock?e.write(`${t.textContent||t.attrs.text||""}

`):e.write(t.textContent||t.attrs.text||"")},support:"fallback"},table:{serialize({state:e,node:t,parent:a,index:o}){if(e.featureToggles.markdownPlus&&e.featureToggles.markdownPlusAddComplexNodes){let a=e.featureToggles.markdownPlusAvoidDuplicatedIdCounter?e.getIdBasedOnIdMap(e,"table",t.attrs):`id-${e.idCounter++}`;e.idMap[a]={type:"table",attributes:t.attrs},e.write(`<custom data-type="table_open" data-id="${a}" />

`),t.content.forEach((a,r)=>e.render(a,t,r)),e.write(`<custom data-type="table_close" />

`)}else{r(t,e.featureToggles,{layout:t.attrs.layout,localId:t.attrs.localId,width:760})||e.updateNonErrorFallbackState(t);let n=i(t);t.content.forEach((r,s)=>{try{e.render(r,t,s,{headerRowPresent:n,skipFallback:!0})}catch(r){e.updateFallbackState(r,t),e.nodes.fallback.serialize({state:e,node:t,parent:a,index:o})}}),e.closeBlock(t)}},support:"partial"},tableRow:{serialize({state:e,node:t,parent:a,index:n,options:i}){if(e.featureToggles.markdownPlus&&e.featureToggles.markdownPlusAddComplexNodes){let r=e.featureToggles.markdownPlusAvoidDuplicatedIdCounter?e.getIdBasedOnIdMap(e,"table",t.attrs):`id-${e.idCounter++}`;e.idMap[r]={type:"table",attributes:t.attrs},e.write(`<custom data-type="tr_open" data-id="${r}" />

`),t.content.forEach((r,o)=>{try{e.render(r,t,o,{skipFallback:!0})}catch(r){e.updateFallbackState(r,t),e.nodes.fallback.serialize({state:e,node:t,parent:a,index:n})}}),e.write(`<custom data-type="tr_close" />

`)}else if(r(t,e.featureToggles)||e.updateNonErrorFallbackState(t),t.content.forEach((r,o)=>{try{e.render(r,t,o,{...i,skipFallback:!0})}catch(r){e.updateFallbackState(r,t),e.nodes.fallback.serialize({state:e,node:t,parent:a,index:n})}}),e.write("|"),e.ensureNewLine(),o(t)||s(t,a)){for(let a=0;a<t.childCount;a++)e.write("| --- ");e.write("|"),e.ensureNewLine()}},support:"partial"},tableHeader:{serialize({state:e,node:t,parent:a,index:o,options:n}){if(e.featureToggles.markdownPlus&&e.featureToggles.markdownPlusAddComplexNodes){let r=e.featureToggles.markdownPlusAvoidDuplicatedIdCounter?e.getIdBasedOnIdMap(e,"table",t.attrs):`id-${e.idCounter++}`;e.idMap[r]={type:"table",attributes:t.attrs},e.write(`<custom data-type="th_open" data-id="${r}" />

`),t.content.forEach((r,n)=>{try{e.render(r,t,n,{skipFallback:!0})}catch(r){e.updateFallbackState(r,t),e.nodes.fallback.serialize({state:e,node:t,parent:a,index:o})}}),e.write(`<custom data-type="th_close" />

`)}else r(t,e.featureToggles)||e.updateNonErrorFallbackState(t),d({state:e,node:t,parent:a,index:o,options:n})},support:"partial"},tableCell:{serialize({state:e,node:t,parent:a,index:o,options:n}){if(e.featureToggles.markdownPlus&&e.featureToggles.markdownPlusAddComplexNodes){let r=e.featureToggles.markdownPlusAvoidDuplicatedIdCounter?e.getIdBasedOnIdMap(e,"table",t.attrs):`id-${e.idCounter++}`;e.idMap[r]={type:"table",attributes:t.attrs},e.write(`<custom data-type="td_open" data-id="${r}" />

`),t.content.forEach((r,n)=>{try{e.render(r,t,n,{skipFallback:!0})}catch(r){e.updateFallbackState(r,t),e.nodes.fallback.serialize({state:e,node:t,parent:a,index:o})}}),e.write(`<custom data-type="td_close" />

`)}else r(t,e.featureToggles)||e.updateNonErrorFallbackState(t),d({state:e,node:t,parent:a,index:o,options:n})},support:"partial"}},E={em:{open:"_",close:"_",mixable:!0,expelEnclosingWhitespace:!0},strong:{open:"**",close:"**",mixable:!0,expelEnclosingWhitespace:!0},strike:{open:"~~",close:"~~",mixable:!0,expelEnclosingWhitespace:!0},link:{open:"[",close:(e,t)=>"]("+t.attrs.href+")"},code:{open:"`",close:"`"}}}),s("b4emg",function(e,a){t(e.exports,"getEmptyADF",()=>r);let r=()=>({type:"doc",version:1,content:[]})}),s("kAaxz",function(e,a){t(e.exports,"ConvoAIResponseState",()=>o),t(e.exports,"getDefaultConvoAIStreamingState",()=>n);var r,o=((r={}).Initialization="Initialization",r.ChannelId="ChannelId",r.AnswerPart="AnswerPart",r.FinalResponse="FinalResponse",r.FollowUp="FollowUp",r.Error="Error",r.Trace="Trace",r);function n(){return{content:null,responseState:"Initialization"}}}),s("3j1mV",function(e,a){t(e.exports,"useConfluencePageAri",()=>o);var r=n("gwFzn");let o=(e,t,a)=>({pageAri:(0,r.useMemo)(()=>{try{switch(a){case"page":return n("qwuI3").ConfluencePageAri.create({siteId:e,pageId:t}).toString();case"blogpost":return n("4GAdN").ConfluenceBlogpostAri.create({siteId:e,blogpostId:t}).toString();case"whiteboard":return n("5wRM9").ConfluenceWhiteboardAri.create({siteId:e,whiteboardId:t}).toString()}}catch{return null}},[a,e,t])})}),s("iIEgX",function(e,a){t(e.exports,"useObservableEffect",()=>s);var r=n("gwFzn"),o=n("cC77I");function s(e,t){let[a]=(0,r.useState)(()=>new(0,o.Subject)),[n]=(0,r.useState)(()=>e(a));(0,r.useEffect)(()=>{let e=n.subscribe();return()=>{e.unsubscribe()}},[n]);let s=(0,r.useCallback)(e=>a.next(e),[a]);return(0,r.useEffect)(()=>{a.next(t)},t),[s]}}),s("aXpOY",function(a,r){t(a.exports,"useStatefulObservableLazyEffect",()=>l);var o=n("gwFzn"),s=n("eH9u1"),i=n("cC77I");function l(t,a){let[r]=(0,o.useState)(()=>new(0,i.Subject)),[n]=(0,o.useState)(()=>t(r)),l=(0,o.useRef)(a),d=(0,o.useCallback)(t=>{let a=n.subscribe({next:a=>{e(s)(a,l.current)||(l.current=a,t())},error:e=>console.error(e),complete:()=>r.complete()});return()=>a.unsubscribe()},[r,n]),c=(0,o.useCallback)(()=>l.current,[l]),u=(0,o.useCallback)(e=>{r.next(e)},[r]);return[(0,o.useSyncExternalStore)(d,c),u]}}),s("cPtvM",function(a,r){t(a.exports,"convoAIStreamingEffect",()=>P);var o=n("eH9u1"),s=n("guQFZ"),i=n("2C39U"),l=n("eJ5lO"),d=n("4iZtC"),c=n("7CiAC"),u=n("2HUA6"),p=n("eByKY"),f=n("69nRD"),m=n("kkxph"),g=n("8EEqM"),E=n("bTavj");let h=(e,t)=>({requestInitParams:{method:"POST",headers:new Headers({...t.headers}),body:JSON.stringify(e)},url:`${t.baseUrl}/${t.apiPath}`}),b=n("iQFRZ").Lens.fromNullableProp()("baseUrl","/gateway/api/assist/api/ai"),C=n("iQFRZ").Lens.fromNullableProp()("enablePartialJson",!1),y=n("iQFRZ").Lens.fromNullableProp()("enableFollowUp",!1),w=n("iQFRZ").Lens.fromNullableProp()("enableLocalVerboseLogs",!1),I=n("iQFRZ").Lens.fromNullableProp()("enableTraceMessage",!1),k=n("iQFRZ").Lens.fromNullableProp()("skip",!1),T=n("iQFRZ").Lens.fromNullableProp()("content-type","application/json;charset=UTF-8"),x=n("iQFRZ").Lens.fromNullableProp()("x-issynthetic-traffic","false"),S=e=>({baseUrl:b.get(e),apiPath:e.apiPath,enablePartialJson:C.get(e),enableFollowUp:y.get(e),enableTraceMessage:I.get(e),enableLocalVerboseLogs:w.get(e),timeoutDelay:e.timeoutDelay,skip:k.get(e),headers:function(e){let t={"content-type":T.get(e.headers),"x-product":e.headers["x-product"],"x-experience-id":e.headers["x-experience-id"],"x-issynthetic-traffic":x.get(e.headers)};return e.headers["x-channel-id"]&&(t["x-channel-id"]=e.headers["x-channel-id"]),t}(e)});var _=n("iX7e9"),A=n("bddW2");async function*R(e){if(200===e.status&&e.body)try{let t=e.body.getReader(),a=new TextDecoder("utf-8"),r="",o=!1;for(;!o;){let{value:e,done:n}=await t.read(),s=a.decode(e);o=n;let i=(r=`${r}${s}`).split("\n");for(;i.length>1;){let e=i.shift(),t=JSON.parse(e);yield t}r=i[0]}return}catch(a){let t="";"string"==typeof a?t=a.toUpperCase():a instanceof Error&&(t=a.message),yield{type:"ERROR",message:{content:`[Stream Error]: ${t}. locked status: ${e.body.locked}. statusCode: ${e.status}`,message_template:n("93WqG").ConvoAIErrorMessage.UNEXPECTED,status_code:n("93WqG").CONVOAI_DEFAULT_ERROR_CODE}};return}let t=await e.text();try{let a=JSON.parse(t);yield(0,A.match)({status:e.status,body:e.body,text:t,json:a}).returnType().with({status:201},({text:t,status:a,json:r})=>({type:"ERROR",message:{content:`[HTTP Error]: No answer was generated by Open AI. Raw error details: ${t}. statusCode: ${a}`,message_template:n("93WqG").ConvoAIErrorMessage.BAD_REQUEST,status_code:e.status},jsonRawResponse:r})).with({status:400},({text:t,status:a,json:r})=>({type:"ERROR",message:{content:`[HTTP Error]: BAD_REQUEST or NO_AGENT or EXCEEDING_CONTEXT_LENGTH_ERROR. Raw error details: ${t}. statusCode: ${a}`,message_template:n("93WqG").ConvoAIErrorMessage.BAD_REQUEST,status_code:e.status},jsonRawResponse:r})).with({status:403},({text:t,status:a,json:r})=>({type:"ERROR",message:{content:`[HTTP Error]: FEATURE_DISABLED_ON_SITE or FEATURE_DISABLED or HIPAA_CONTENT_DETECTED. Raw error details: ${t}. statusCode: ${a}`,message_template:n("93WqG").ConvoAIErrorMessage.BAD_REQUEST,status_code:e.status},jsonRawResponse:r})).with({status:429},({text:t,status:a,json:r})=>({type:"ERROR",message:{content:`[HTTP Error]: RATE_LIMIT or OPENAI_RATE_LIMIT_USER_ABUSE. Raw error details: ${t}. statusCode: ${a}`,message_template:n("93WqG").ConvoAIErrorMessage.RATE_LIMIT,status_code:e.status},jsonRawResponse:r})).with({status:500},({text:t,status:a,json:r})=>({type:"ERROR",message:{content:`[HTTP Error]: INTERNAL_SERVER_ERROR. Raw error details: ${t}. statusCode: ${a}`,message_template:n("93WqG").ConvoAIErrorMessage.UNEXPECTED,status_code:e.status},jsonRawResponse:r})).with({body:A.P.nullish},({text:t,status:a,json:r})=>({type:"ERROR",message:{content:`[Error]: response.body is missing. Raw error details: ${t}. statusCode: ${a}`,message_template:n("93WqG").ConvoAIErrorMessage.UNEXPECTED,status_code:e.status},jsonRawResponse:r})).otherwise(({text:t,status:a,json:r})=>({type:"ERROR",message:{content:`[HTTP Error]: OTHER_SERVER_ERROR. Raw error details: ${t}. statusCode: ${a}`,message_template:n("93WqG").ConvoAIErrorMessage.UNEXPECTED,status_code:e.status},jsonRawResponse:r}))}catch(a){yield{type:"ERROR",message:{content:`[HTTP Error]: UNABLE_TO_PARSE_HTTP_ERROR. Raw error details: ${t}. statusCode: ${e.status}`,message_template:n("93WqG").ConvoAIErrorMessage.UNEXPECTED,status_code:e.status}}}}var v=n("aGU6X");let N=(e,t,a)=>{t.enableLocalVerboseLogs&&console.info(`[@atlassian/convo-ai-streaming] [${e}]:`,a)};function P(t){return t.pipe((0,f.skipWhile)(({inputs:[e,{skip:t}]})=>!!t),(0,c.distinctUntilChanged)(({inputs:[t,a,r]},{inputs:[n,s,i]})=>e(o)(t,n)&&e(o)(a,s)&&r===i),(0,p.map)(({inputs:[e,t]})=>({config:S(t),request:e})),(0,p.map)(({request:e,config:t})=>({requestConfig:h(e,t),config:t})),(0,m.switchMap)(({requestConfig:e,config:t})=>{N("pre request data",t,e);let a=function(e){let t=new(0,_.BehaviorSubject)((0,n("kAaxz").getDefaultConvoAIStreamingState)());return fetch(e.url,{credentials:"include",...e.requestInitParams}).then(e=>R(e)).then(async e=>{let a="",r=0;for await(let o of e){let e=t.getValue();switch(o.type){case"ANSWER_PART":a+=o.message.content,t.next({...e,responseState:n("kAaxz").ConvoAIResponseState.AnswerPart,content:a,answerChunkIndex:r}),r+=1;break;case"CHANNEL_ID":let s=o.message.content;t.next({...e,responseState:n("kAaxz").ConvoAIResponseState.ChannelId,content:s,answerChunkIndex:void 0});break;case"FINAL_RESPONSE":a=o.message.content,t.next({...e,responseState:n("kAaxz").ConvoAIResponseState.FinalResponse,content:a,answerChunkIndex:void 0});break;case"FOLLOW_UP_QUERIES":t.next({...e,responseState:n("kAaxz").ConvoAIResponseState.FollowUp,answerChunkIndex:void 0,followUpContent:o.message.follow_ups??[]});break;case"TRACE":t.next({...e,responseState:n("kAaxz").ConvoAIResponseState.Trace,traceContent:o.message?.content??null,answerChunkIndex:void 0});break;case"ERROR":t.next({...e,responseState:n("kAaxz").ConvoAIResponseState.Error,answerChunkIndex:void 0,error:{...o}})}}}).finally(()=>{t.complete()}),t}(e);return t.timeoutDelay?a.pipe((0,E.timeout)(t.timeoutDelay),(0,p.map)(e=>({config:t,state:e}))):a.pipe((0,p.map)(e=>({config:t,state:e})))})).pipe((0,u.filter)(({config:e,state:t})=>(!!e.enableFollowUp||t.responseState!==n("kAaxz").ConvoAIResponseState.FollowUp)&&(!!e.enableTraceMessage||t.responseState!==n("kAaxz").ConvoAIResponseState.Trace)),(0,p.map)(({config:e,state:t})=>{N("response data",e,t);let a=function(e,t){if(e.responseState!==n("kAaxz").ConvoAIResponseState.Initialization&&t.enablePartialJson&&e.content)try{let t=(0,v.parse)(e.content);return{...e,content:t}}catch(e){}return e}(t,e);return N("post json parsing content",e,t),{state:a,config:e}}),(0,g.timeInterval)(),(0,l.concatMap)(({value:{state:e,config:t},interval:a})=>{if(!t.delayChunkUpdate)return(0,s.of)(e);let{time:r,gap:o}=t.delayChunkUpdate;return a<o?(0,s.of)(e).pipe((0,d.delay)(r)):(0,s.of)(e)}),(0,i.catchError)(e=>{if("TimeoutError"===e.name){let t={responseState:n("kAaxz").ConvoAIResponseState.Error,content:null,answerChunkIndex:void 0,error:{type:"ERROR",message:{content:e.message,message_template:n("93WqG").ConvoAIErrorMessage.TIMEOUT,status_code:n("93WqG").CONVOAI_DEFAULT_ERROR_CODE}}};return(0,s.of)(t)}let t={responseState:n("kAaxz").ConvoAIResponseState.Error,content:null,error:{type:"ERROR",message:{content:e.message,message_template:n("93WqG").ConvoAIErrorMessage.UNEXPECTED,status_code:n("93WqG").CONVOAI_DEFAULT_ERROR_CODE}}};return(0,s.of)(t)}))}}),s("93WqG",function(e,a){t(e.exports,"ConvoAIErrorMessage",()=>o),t(e.exports,"CONVOAI_DEFAULT_ERROR_CODE",()=>n);var r,o=((r={}).RATE_LIMIT="RATE_LIMIT",r.ANSWER_UNAVAILABLE_FOR_CONTENT="ANSWER_UNAVAILABLE_FOR_CONTENT",r.ACCEPTABLE_USE_VIOLATIONS="ACCEPTABLE_USE_VIOLATIONS",r.NOT_ENOUGH_CONTENT_ERROR="NOT_ENOUGH_CONTENT_ERROR",r.NOT_FOUND="NOT_FOUND",r.INTERNAL_SERVER_ERROR="INTERNAL_SERVER_ERROR",r.BAD_REQUEST="BAD_REQUEST",r.UNEXPECTED="UNEXPECTED",r.TIMEOUT="TIMEOUT",r);let n=0}),s("cfwlu",function(a,r){t(a.exports,"GicAnywhere",()=>u);var o=n("7UHDa"),s=n("gwFzn"),i={};i=new URL("error.5fbc7fe9.png",import.meta.url).toString();let l=7e3,d=(0,n("2nPZH").defineMessages)({iFrameLoading:{id:"jira-ai.gic-anywhere.iframe-loading",defaultMessage:"Loading work item details, this might take a few seconds."},iFrameSlowLoading:{id:"jira-ai.gic-anywhere.iframe-slow-loading",defaultMessage:"It is taking longer than usual to load your work item.{br}Give it a few more seconds, or try again later."},openInJiraButton:{id:"jira-ai.gic-anywhere.open-in-jira-button",defaultMessage:"Log in to Jira to view"},errorHeader:{id:"jira-ai.gic-anywhere.error-header",defaultMessage:"Something's gone wrong"},errorBody:{id:"jira-ai.gic-anywhere.error-body",defaultMessage:"Try opening this in Jira. If the problem persists, please contact Atlassian support."}}),c={loading:"loading",timeout:"timeout",error:"error",idle:"idle"},u=e=>(0,o.jsx)(n("0XxK1").AnalyticsProvider,{children:(0,o.jsx)(n("fVTNs").ContextWrapper,{sourceType:n("bHD89").MODAL,sourceName:"gicAnywhere",children:(0,o.jsx)(f,{...e})})}),p={hiddenDisplay:"_1e0cglyw",gicAnywhere:"_1bsb1osq _4t3i1osq",loadingScreen:"_1e0c1txw _2lx21bp4 _4cvr1h6o _1bah1h6o _y3gn1h6o"},f=({cloudId:t,overrideCloudId:a,configuration:r,summary:u,assignee:f,descriptionAdf:g,consumer:E,timeoutMs:h=l,onInit:b,onSuccess:C,onFailure:y,onClose:w,onTimeout:I,projectId:k,issueTypeId:T,issueTypes:x,isPayloadReady:S=!1,additionalMappedFields:_})=>{let{availableSites:A,domainName:R,isOverrideSiteAvailable:v}=(0,n("g5o3i").useGetDomainAndAvailableSites)({cloudId:t,overrideCloudId:a}),N=A&&A.length>1,[P,M]=(0,s.useState)(c.loading),{createAnalyticsEvent:O}=(0,n("inPa6").useAnalyticsEvents)(),{formatMessage:j}=(0,n("dBxQj").default)();(0,s.useEffect)(()=>{let e=(()=>{switch(P){case c.loading:return setTimeout(()=>{(0,n("3C50A").fireOperationalAnalytics)(O({}),"globalIssueCreateEmbed timedOut",{consumer:E,timeoutMs:h}),M(c.timeout),I?.()},h);case c.timeout:return setTimeout(()=>{(0,n("3C50A").fireOperationalAnalytics)(O({}),"globalIssueCreateEmbed error",{consumer:E,timeoutMs:2*h}),M(c.error),y(Error("GIC has timed out"))},h)}})();return()=>e&&clearTimeout(e)},[E,O,y,I,P,h]);let D=(0,s.useCallback)(()=>(M(c.idle),{summary:u||"No summary provided",descriptionAdf:g||(0,n("b4emg").getEmptyADF)(),projectId:k,issueTypeId:T,issueTypes:x?.join(","),assignee:f,fieldData:_}),[u,g,k,T,x,f,_]),$=(0,s.useMemo)(()=>{switch(P){case c.timeout:case c.loading:return(0,o.jsxs)(n("gdv5Z").default,{testId:"gic-anywhere-loading",xcss:(0,n("1Whri").cx)(p.gicAnywhere,p.loadingScreen),children:[(0,o.jsx)(n("9hlns").default,{size:"large"}),(0,o.jsx)(n("iXCQx").default,{children:j(P===c.timeout?d.iFrameSlowLoading:d.iFrameLoading,{br:(0,o.jsx)("br",{})})})]});case c.error:return(0,o.jsx)(n("gdv5Z").default,{testId:"gic-anywhere-error",xcss:p.gicAnywhere,children:(0,o.jsx)(n("abC4X").default,{header:j(d.errorHeader),description:j(d.errorBody),primaryAction:(0,o.jsx)(n("7p4As").default,{onClick:()=>{w()},href:R||"/",target:"_blank",appearance:"primary",children:j(d.openInJiraButton)}),imageUrl:e(i),imageWidth:188,maxImageWidth:188,maxImageHeight:250})});default:return}},[P,j,R,w]);return(0,o.jsxs)(o.Fragment,{children:[$,(0,o.jsx)(n("fwDOR").default,{name:"gic-anywhere-iframe-loading",hold:P===c.loading}),(0,o.jsx)(n("gdv5Z").default,{xcss:P!==c.idle?p.hiddenDisplay:p.gicAnywhere,children:void 0!==R&&(0,o.jsx)(m,{domainName:R,consumer:E,onGICReady:D,onInit:b,onSuccess:C,onFailure:y,onClose:w,configuration:r,displaySitePicker:N,isPayloadReady:S,overrideCloudId:v?a:void 0})})]})},m=({onGICReady:e,consumer:t,domainName:a,overrideCloudId:r,onClose:i,onFailure:l,onSuccess:d,onInit:c,configuration:u,displaySitePicker:p=!0,isPayloadReady:f=!1})=>{(0,n("RUXAI").di)(g);let m=(0,s.useRef)(null),{createAnalyticsEvent:E}=(0,n("inPa6").useAnalyticsEvents)(),{colorMode:h}=(0,n("cOrQJ").default)(),[b,C]=(0,s.useState)(!1),[y,w]=(0,s.useState)(!1),I=(0,s.useRef)(y),k=(0,s.useRef)(e);k.current=e;let T=(0,s.useMemo)(()=>({product:t,actionSource:"issue-create-anywhere-embed"}),[t]),x=(0,s.useMemo)(()=>{if(c)return(0,n("dh538").fg)("jira_ai_fix_aiwc_duplicated_analytics")?(0,n("0XxK1").debounce)(()=>c(),2e3):c},[c]);(0,s.useEffect)(()=>()=>{x&&"function"==typeof x.cancel&&x.cancel()},[x]),(0,s.useEffect)(()=>{let e=async e=>{if(!m.current?.contentWindow)return;let a=e?.data?.event,r=E({});switch(a){case n("4KAVh").JIRA_EMBED_ISSUE_CREATE_READY:(0,n("3C50A").fireOperationalAnalytics)(r,"globalIssueCreateEmbed initialised",{consumer:t}),w(!0);break;case n("4KAVh").JIRA_EMBED_ISSUE_CREATE_SUCCESS:C(!0),d(e.data.payload),(0,n("3C50A").fireTrackAnalytics)(r,"globalIssueCreateEmbed succeeded",{consumer:t});break;case n("4KAVh").JIRA_EMBED_ISSUE_CREATE_FAILURE:l(Error("issueCreate failed to save")),(0,n("3C50A").fireOperationalAnalytics)(r,"globalIssueCreateEmbed failed",{consumer:t});break;case n("4KAVh").JIRA_EMBED_ISSUE_CREATE_CLOSE:i(b),b||(0,n("3C50A").fireUIAnalytics)(r,"globalIssueCreateEmbed closed",{consumer:t})}};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[m,t,E,c,i,l,d,b,C,w]),(0,s.useEffect)(()=>{f&&y&&Promise.resolve(k.current()).then(e=>{let t=m.current?.contentWindow;if(t){let{fieldData:a,...r}=e??{};t.postMessage({event:n("4KAVh").JIRA_EMBED_ISSUE_CREATE_INIT,payload:{defaultValues:r,...a&&{fieldData:{...a,...r}}}},"*"),x?.()}})},[f,y,k,x]);let S=(0,n("0XxK1").getIframeSrc)({colorMode:h,domainName:a,params:T,displaySitePicker:(0,n("dh538").fg)("jira_ai_gic_embed_exception_on_timeout")?p:!!(0,n("dh538").fg)("inconsistent_iframe_src_site_picker_fix")||p,...u,overrideCloudId:r});return(0,s.useEffect)(()=>{(0,n("dh538").fg)("jira_ai_gic_embed_exception_on_timeout")&&(I.current=y)},[y]),(0,s.useEffect)(()=>{(0,n("dh538").fg)("jira_ai_gic_embed_exception_on_timeout")&&w(!1)},[S]),(0,s.useEffect)(()=>{if(!(0,n("dh538").fg)("jira_ai_gic_embed_exception_on_timeout"))return;let e=setTimeout(()=>{if(!I.current)throw Error("jira-ai/gic-anywhere: The latest GIC iframe window was not initialized")},1e4);return()=>clearTimeout(e)},[S]),(0,o.jsx)(g,{name:"gic-anywhere-iframe",sandbox:void 0,ref:m,height:"100%",width:"100%",frameBorder:0,src:S,"data-testid":"gic-anywhere"})},g=(0,s.forwardRef)((e,t)=>(0,o.jsx)("iframe",{title:"Jira Embed Global Issue Create",ref:t,...e}))}),s("4KAVh",function(e,a){t(e.exports,"ERROR_IFRAME_SOURCE_CHAR_LIMIT_EXCEEDED",()=>r),t(e.exports,"JIRA_EMBED_ISSUE_CREATE_INIT",()=>o),t(e.exports,"JIRA_EMBED_ISSUE_CREATE_READY",()=>n),t(e.exports,"JIRA_EMBED_ISSUE_CREATE_SUCCESS",()=>s),t(e.exports,"JIRA_EMBED_ISSUE_CREATE_FAILURE",()=>i),t(e.exports,"JIRA_EMBED_ISSUE_CREATE_CLOSE",()=>l);let r="Jira GIC Anywhere - Iframe Source character limit exceeded",o="jiraEmbedIssueCreateInit",n="jiraEmbedIssueCreateReady",s="jiraEmbedIssueCreateSuccess",i="jiraEmbedIssueCreateAppFailed",l="jiraEmbedIssueCreateClose"}),s("hzZxz",function(a,r){t(a.exports,"extractAWCDataFromEvent",()=>k);var o=n("f0hBp"),s=n("dKXPX"),i=n("hz0AL"),o=n("f0hBp"),l=n("5XKHf"),d=n("ewFdA"),s=n("dKXPX"),c=n("jIQq0");let u=(e,t)=>e.context.map(e=>e[t]),p=e=>e.payload.analyticsType,f=t=>{let a=u(t,"attributes"),r=t.payload.attributes,n=e(d)(a.reduce((t,a)=>e(d)(t,a),{}),r),i=u(t,"source").filter(Boolean).join(".");return e(s)({...n,namespaces:i},e(o))},m=t=>e(l)(u(t,"source").filter(Boolean)),g=t=>{let{actionSubject:a}=t.payload;return a||e(l)(u(t,"component").filter(Boolean))||e(l)(u(t,"componentName").filter(Boolean))},E=e=>e.payload.action,h=e=>e.payload.actionSubjectId,b=t=>e(l)(u(t,"containerId").filter(Boolean)),C=t=>e(l)(u(t,"containerType").filter(Boolean)),y=t=>e(l)(u(t,"objectId").filter(Boolean)),w=t=>e(l)(u(t,"objectType").filter(Boolean)),I=t=>{let a=e(c)(e(i)(u(t,"tags"))).filter(Boolean);return a.length?a:void 0},k=t=>{let a=p(t),r=f(t),i=m(t),l=g(t);if(a===n("bHD89").SCREEN_EVENT_TYPE)return{type:n("bHD89").SCREEN_EVENT_TYPE,payload:{name:i,attributes:r}};switch(a){case n("bHD89").UI_EVENT_TYPE:case n("bHD89").TRACK_EVENT_TYPE:case n("bHD89").OPERATIONAL_EVENT_TYPE:{let n=E(t),d=h(t),c=b(t),u=C(t),p=y(t),f=w(t),m=I(t);return{type:a,payload:e(s)({action:n,actionSubject:l,actionSubjectId:d,source:i,tags:m,containerType:u,containerId:c,objectType:f,objectId:p,attributes:r},e(o))}}default:return{payload:{source:i,actionSubject:l,attributes:r},type:void 0}}}}),s("g5o3i",function(e,a){t(e.exports,"useGetFirstAvailableSiteDomain",()=>o),t(e.exports,"useGetDomainAndAvailableSites",()=>l);var r=n("gwFzn");let o=({preferredCloudId:e,onComplete:t,onError:a})=>{(0,n("RUXAI").di)(n("0XxK1").getAvailableJiraSites);let[o,s]=(0,r.useState)(void 0),[i,l]=(0,r.useState)([]),[d,c]=(0,r.useState)(!1),[u,p]=(0,r.useState)(void 0);return(0,r.useEffect)(()=>{(async()=>{c(!0);try{let{sites:a}=await (0,n("0XxK1").getAvailableJiraSites)();l(a??[]);let r=(a.find(t=>t.cloudId===e)??a[0])?.url??"";s(r),t?.({domain:r,availableSites:a})}catch(e){a&&a(e),p(e.message)}finally{c(!1)}})()},[e,t,a]),{domain:o,availableSites:i,loading:d,error:u}},s=({onComplete:e,onError:t})=>{(0,n("RUXAI").di)(n("0XxK1").getAvailableJiraSites);let[a,o]=(0,r.useState)([]),[s,i]=(0,r.useState)(!1),[l,d]=(0,r.useState)(void 0),c=(0,r.useRef)(!1);return(0,r.useEffect)(()=>{c.current||(i(!0),(async()=>{try{let{sites:t}=await (0,n("0XxK1").getAvailableJiraSites)();o(t??[]),e?.({availableSites:t})}catch(e){t&&t(e),d(e.message)}finally{i(!1)}})(),c.current=!0)},[e,t]),{availableSites:a,loading:s,error:l}},i=({sites:e,preferredCloudId:t})=>({domain:(e.find(e=>e.cloudId===t)??e[0])?.url??""}),l=({cloudId:e,overrideCloudId:t})=>{let{availableSites:a,loading:r,error:o}=s({}),{domain:l}=i({sites:a,preferredCloudId:e}),{domain:d}=i({sites:a,preferredCloudId:t});if((0,n("dh538").fg)("inconsistent_iframe_src_site_picker_fix")){if(o)throw Error("Failed to fetch available sites");return r?{availableSites:[],domainName:void 0,isOverrideSiteAvailable:void 0}:{availableSites:a,domainName:l,isOverrideSiteAvailable:d}}return{availableSites:a,domainName:l,isOverrideSiteAvailable:d}}}),s("d3UlG",function(e,a){t(e.exports,"useConvoAIStreaming",()=>s);var r=n("gwFzn"),o=n("3CH4j");function s(e,t,a){let s=(0,r.useRef)(crypto.randomUUID()),[i,l]=(0,n("6yCLg").useStatefulObservableEffect)(n("cPtvM").convoAIStreamingEffect,(0,n("kAaxz").getDefaultConvoAIStreamingState)(),[e,t,s.current]);return(0,n("iIEgX").useObservableEffect)(e=>e.pipe((0,o.tap)(([e,t])=>t?.(e))),[i,a]),[i,(0,r.useCallback)(()=>{s.current=crypto.randomUUID(),l({inputs:[e,t,s.current],state:(0,n("kAaxz").getDefaultConvoAIStreamingState)()})},[e,t,l])]}}),s("6yCLg",function(e,a){t(e.exports,"useStatefulObservableEffect",()=>o);var r=n("gwFzn");function o(e,t,a){let[o,s]=(0,n("aXpOY").useStatefulObservableLazyEffect)(e,t);return(0,r.useEffect)(()=>{s({inputs:a,state:t})},a),[o,s]}}),s("0XxK1",function(e,a){t(e.exports,"getIframeSrc",()=>l),t(e.exports,"getAvailableJiraSites",()=>c),t(e.exports,"AnalyticsProvider",()=>u),t(e.exports,"debounce",()=>p);var r=n("7UHDa"),o=n("gwFzn");let s={env:"prod",product:"jira"},i="auto",l=({colorMode:e=i,domainName:t="",overrideCloudId:a,params:r,onFailure:o,displaySitePicker:s,disableProjectDropdown:l,displayOnlyRequiredFields:d})=>{let c=new URLSearchParams(r);c.append("postMessageInit","1"),!1===s&&c.append("displaySitePicker","false"),l&&c.append("disableProjectDropdown","true"),d&&c.append("displayOnlyRequiredFields","true"),e&&c.append("themeMode",e),a&&c.append("overrideCloudId",a);let u=`${t}/jira/issues/create/embed?${c}`;return u.length>2048&&o?.(Error(n("4KAVh").ERROR_IFRAME_SOURCE_CHAR_LIMIT_EXCEEDED)),u},d=["jira-software.ondemand","jira-core.ondemand","jira-servicedesk.ondemand","jira-product-discovery"];async function c(){let e={method:"POST",credentials:"include",headers:{Accept:"application/json","Cache-Control":"no-cache","Content-Type":"application/json"},body:JSON.stringify({products:d})},t=await fetch("/gateway/api/available-sites",e);if(t.ok)return t.json();throw t}let u=e=>{let t=(0,o.useRef)(new(0,n("a9sR2").default)(s,{})),a=(0,o.useCallback)(e=>{let{type:a,payload:r}=e;switch(a){case n("bHD89").UI_EVENT_TYPE:t.current.sendUIEvent(r);break;case n("bHD89").TRACK_EVENT_TYPE:t.current.sendTrackEvent(r);break;case n("bHD89").OPERATIONAL_EVENT_TYPE:t.current.sendOperationalEvent(r);break;case n("bHD89").SCREEN_EVENT_TYPE:t.current.sendScreenEvent(r.name,null,r.attributes)}},[]);return(0,r.jsx)(n("kDuN4").default,{channel:n("bHD89").ANALYTICS_BRIDGE_CHANNEL,onEvent:e=>a((0,n("hzZxz").extractAWCDataFromEvent)(e)),children:e.children})},p=(e,t)=>{let a;if(!(0,n("dh538").fg)("jira_ai_fix_aiwc_duplicated_analytics"))return e;let r=(...r)=>{clearTimeout(a),a=setTimeout(()=>{a=void 0,e(...r)},t)};return r.cancel=()=>{clearTimeout(a)},r}}),a.rlb("lmEoo");
//# sourceMappingURL=FullPageEditorComponent.cd572862.js.map
