/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
v5.0.0-next.94 */
import{f as d}from"./RDOPAVSY.js";import{q as c}from"./GNLRKAD5.js";function L(t,r,m,u){if(!r)return[];let e=Array.isArray(r)?r:[r];if(!e.length)return[];let l=c(m);return t.filter(o=>e.some(a=>l.test(String(o[a]??""))))}function N(t){return t?`${t.portal.url}/home/item.html?id=${t.id}`:""}function C(t,r,m="add",u){if(!t)return;let e=t.getSelection(),l=e&&(e.startLineNumber!==e.endLineNumber||e.startColumn!==e.endColumn),o=[],a=t.getValue()??"";if(m==="replace"){let i=`${u}
${r}`,s=t.getModel(),n=s?.getLineCount()??1,f=s?.getLineMaxColumn(n)??1;o=[{range:{startLineNumber:1,startColumn:1,endLineNumber:n,endColumn:f},text:i}]}else{let i=l?{startLineNumber:e.startLineNumber,startColumn:e.startColumn,endLineNumber:e.endLineNumber,endColumn:e.endColumn}:(()=>{let n=t.getPosition();return{startLineNumber:n?.lineNumber??1,startColumn:n?.column??1,endLineNumber:n?.lineNumber??1,endColumn:n?.column??1}})(),s=!1;if(u){let n=u.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");s=!new RegExp(`^\\s*${n}\\s*$`,"mu").test(a)}s&&o.push({range:{startLineNumber:1,startColumn:1,endLineNumber:1,endColumn:1},text:`${u}
`}),o.push({range:i,text:r})}try{t.pushUndoStop(),t.executeEdits("insertText",o),t.pushUndoStop(),t.focus()}catch(i){console.error("Failed to edit model:",i)}}function g(t){try{return d(t)}catch{return t}}export{L as a,N as b,C as c,g as d};
